3 ms·
I find Go’s version worse in that it does not allow you to elide the index (which is not needed most of the time). You have to write `for _, s := range vec`, as
by xigoi 3mo ago
I find Go’s version worse in that it does not allow you to elide the index (which is not needed most of the time). You have to write `for _, s := range vec`, as `for s := range vec` makes s the index.
- WalterBright 3mo agoTo clarify, foreach (s; vec) works if you don't need the index. To be able to modify s in place: foreach (ref s; vec) s = "replacement";
- xigoi 3mo agoI was talking about Go. I know you don’t need the index in D.