5 ms·
Is it just me or is this kind of ugly in the first place? We're trying to mix logic that executes on each element in a sequence, with logic that controls how t
by plaguuuuuu 14y ago
Is it just me or is this kind of ugly in the first place?
We're trying to mix logic that executes on each element in a sequence, with logic that controls how to iterate over that sequence. That is, a "return 42" statement will tell .each to stop iterating, but its contained within a block that is supposed to do things to individual elements.
The mathematical concept just doesn't sit right with me.. I guess if all you have as an iterator is 'each' then that would necessitate finding an additional way to modify iteration in some way, but still.. I don't like the fact that a return statement can break out of something outside of its own scope
edit: even the low-level alternative seems nicer
for(blah;blah;blah) {
stuff;
}