Y
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
WalterBright
13 days ago
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";
link
xigoi
13 days ago
I was talking about Go. I know you don’t need the index in D.
link