2 ms·
Where this kills me is ambiguous commas. something = [ alpha beta, gamma ] I have no idea if I just invoked alpha(beta, gamma) and put the result into a s
by pavel_lishin 8y ago
Where this kills me is ambiguous commas.
something = [ alpha beta, gamma ]
I have no idea if I just invoked alpha(beta, gamma) and put the result into a single-member array, or if I've got an array with two elements - alpha(beta) and gamma.
- dragonwriter 8y agoIt's not actually ambiguous; though it is a bit of language-specific syntax to learn.
- iamrohitbanga 8y agoAgreed. It is the "idiomatic" way of writing code in Ruby. I love Java but writing lambda expressions in Java with deeply nested parenthesis makes the code really ugly and less readable esp with chaining. As far as I understand, Ruby style is writing the code in the most elegant way to increase readability and (hopefully) reduce chances of bugs.
- pavel_lishin 8y agoSo what would you expect my example above do, at a glance? Or is my example something that a good Ruby developer never write at all?
- pavel_lishin 8y agoIt's not ambiguous to the computer, but it is ambiguous to a human at a glance.
- techazard 8y agoYep you can create ambiguous nasty code like this. It's is clearly not expressing intent, so you would add parentheses.