3 ms·
I expected this new feature to use the -> token but they went with => instead. Is there any reason why they overloaded the hash rocket? Even the simple example
by matheusmoreira 6y ago
I expected this new feature to use the -> token but they went with => instead.
Is there any reason why they overloaded the hash rocket? Even the simple examples in the article look like somewhat malformed hashes to me!
3 => box_height
[170, 65] => height, weight
traits => height, weight
How does the parser tell them apart?
- dragonwriter 6y ago> Is there any reason why they overloaded the hash rocket? The fact that it's used for a kinda similar purpose in rescue clauses is a factor. > How does the parser tell them apart? Unbraced hashes can only occur in last-argument-of-function position, so unless it's naked (not a parenthesized subexpression) in that position, it can't be an unbraced hash.