Hi:

when I use map with joiner, I found that function in map are called. In the document it says joiner is lazy, so why is the function called?

say:

int[] mkarray(int a) {
   writeln("mkarray called!");
   return [a * 2]; // just for test
}

void main() {
   auto xs = [1, 2];
   auto r = xs.map!(x=>mkarray(x)).joiner;
}

running this will get the output:

mkarray called!
mkarray called!

I suppose joiner does not consume?

when I actually consume the result by writlen, I get more output:

mkarray called!
mkarray called!
[2mkarray called!
mkarray called!
, 4]

I don't understand

Reply via email to