map on char[] converts to dchar?

Johan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 24 02:05:43 PDT 2017


Hi all,
   What am I doing wrong here?
```
import std.algorithm;
int foo(char c) {
     return 123;
}
auto mapFoo(char[] chars) {
     return chars.map!(a => a.foo);
}
```
errors with:
main.d(14): Error: function main.foo (char c) is not callable 
using argument types (dchar)
/Library/D/dmd/src/phobos/std/algorithm/iteration.d(492):        
instantiated from here: MapResult!(__lambda2, char[])
main.d(14):        instantiated from here: map!(char[])

(Things work after changing foo to accept dchar, but I don't want 
that.)

Thanks,
   Johan



More information about the Digitalmars-d-learn mailing list