cannot implicitly convert expression (array(map(split("a")))) of type string[][] to immutable(string[][])

Fangrui Song via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 28 23:37:00 PST 2017


What cannot `string[][]` be implicitly converted to 
`immutable(string[][])` as in `not_compilable`?



import std.stdio, std.range, std.algorithm, std.array;

void main() {
   immutable not_compilable = "a".split.map!(x => x.split).array;
   static immutable compilable0 = "a".split.map!(x => 
x.split).array;
   immutable compilable1 = "a".split.map!"a.split".array;
}



% dmd --version
DMD64 D Compiler v2.073.0
Copyright (c) 1999-2016 by Digital Mars written by Walter Bright

% dmd a.d
a.d(3): Error: cannot implicitly convert expression 
(array(map(split("a")))) of type string[][] to 
immutable(string[][])



More information about the Digitalmars-d mailing list