How to use map?
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 11 05:58:49 PST 2014
Lemonfiend:
> If I instead do ie. map!`cast(int)a` it works fine.
> What am I missing?
Generally don't use casts, unless you know what you are doing
(and often you don't).
The code you were trying to write:
struct Foo(T) {
T t;
}
void main() {
import std.stdio, std.algorithm, std.array;
float[] vals = [1.1, 2.1, 3.1, 4.1];
auto arr = vals.map!(Foo!float).array;
arr.writeln;
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list