On Thursday, 3 September 2015 at 22:48:01 UTC, Jordan Wilson
wrote:
On Thursday, 3 September 2015 at 22:21:57 UTC, Namal wrote:
ep18.d(10): Error: no property 'split' for type 'char[]'
/usr/include/dmd/phobos/std/algorithm.d(427):
instantiated from here: MapResult!(__lambda1, ByLine!(char,
char))
ep18.d(10): instantiated from here: map!(ByLine!(char,
char))
and then a long list to the end of my code
Error: undefined identifier a
Hmm, seems I forgot to add std.string, now it works, but words
seems not to be an array, at least I cannot access it like an
array. words[0][0] leads to
Error: no [] operator overload for type MapResult!(__lambda1,
ByLine!(char, char))
So is is a map? How can I convert all the elements in it to
integer and store it in a real array?
I believe it's by using array:
auto words = file.byLine() // you've all lines in
range
.map!(a => a.split).array();
Sorry, I didn't notice the "convert all the elements in it to
integer" part.
I think I saw reference to the to! before...that is one way to
convert.
auto words = file.byLine() // you've all lines in range
.map!(a => a.split)
.map!(a => to!int(a)).array();