3 ms·
I don't buy this argument. This is syntactically valid ruby, current state: tuple.collect{ |x,y,z| [x * 3, y * 3] } and so is this: tuple.collect{ |y,z| [x
by yebyen 8y ago
I don't buy this argument.
This is syntactically valid ruby, current state:
tuple.collect{ |x,y,z| [x * 3, y * 3] }
and so is this:
tuple.collect{ |y,z| [x * 3, y * 3, z * 3] }
The last one will generate a runtime error (unless "x" is already defined in the closed-over scope the block exists inside of, in that case it might be valid and correct.)
But both are valid Ruby expressions.
Neither are less inscrutable than:
tuple.collect{ [@1 * 3, @2 * 3, @3 * 3] }
This expression will return nil for @3 if only two arguments are passed in, again it's a perfectly valid Ruby expression, and you'll get a runtime error from inside of the block in this case, just like the pre-existing standard block syntaxes.
It's up to the author of the code to create readable constructions that aren't misleading or confusing. There's no reason why this tool is innately bad, more tools can only make it more likely that the author will find an expressive and clear way to say exactly what they're doing without writing something confusing or redundant.
From a language purist perspective, these are all very good reasons not to use Ruby at all. I don't think that adding numbered positional params makes it worse in any objective sense.