arrays and foreach
i have this example program: --- void main() { int[3] a; foreach (p; a) p = 42; writeln(a); } --- after running it, i expect to get [42, 42, 42] but instead i get [0, 0, 0] (i know that you can do a[] = 42, it's just a trivial example). So it seems that you cannot write int
Re: arrays and foreach
On Tuesday, 17 April 2012 at 00:00:57 UTC, Andrej Mitrovic wrote: On 4/17/12, darkstalker wrote: It possible to have 'p' passed by reference? Yes and the answer is in the question: foreach (ref p; a) p = 42; thanks, it works