Re:Fixing for Loops in Go 1.22
by tuetuopay on Wednesday September 20, 2023 @08:42AM
(#37583421)
You don't need to go the python or ruby route to get such benefits. I daily write rust that has a pretty comprehensive iterator system, while still getting the nitty-gritty in your hands. As some other commenter put it, `x.iter().map(function).collect()` is mentally translated to "apply function to the collection x" at a glance.
between
var y []int
for _, x := range x {
y = append(y, function(x))
}
and
let y = x.iter().map(function).collect();
I'll take the second form any day. You express the flow of information, and think about transformations to your collections.
between
and I'll take the second form any day. You express the flow of information, and think about transformations to your collections.