Hacker News new | ask | show | jobs
by xigoi 13 days 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.
1 comments

To 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";
I was talking about Go. I know you don’t need the index in D.