array as parameter

Paul via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 7 13:56:13 PDT 2014


Dynamic array is really reference. Right? But why modification of 
parameter in this case does not work:

void some_func(string[] s) {
  s ~= "xxx"; s ~= "yyy";
}

but this works:

void some_fun(ref string[] s) {
  s ~= "xxx"; s ~= "yyy";
}

In the 1st case s is reference too, is not it?


More information about the Digitalmars-d-learn mailing list