4 ms·
I was sad to see => aka "hashrocket" syntax go, and it still slips in sometimes... but it is nice being able to use the same hash syntax in Ruby and JS. What I
by peteforde 8y ago
I was sad to see => aka "hashrocket" syntax go, and it still slips in sometimes... but it is nice being able to use the same hash syntax in Ruby and JS.
What I'm intrigued by is the author's suggestion that there's more to the change than a relatively minor syntax change. Is there more to the story? I always assumed that both syntaxes are functionally identical.
- rlue 8y ago> What I'm intrigued by is the author's suggestion that there's more to the change than a relatively minor syntax change. I don't remember him saying that about hash literals. All I caught was that he doesn't like how it's limited to expressing only symbol-keyed hashes. Maybe I missed something, though.
- peteforde 8y agoThat was exactly what I didn't pick up on, and you took for granted. I only rarely use non-symbol keys, so it hadn't dawned on me that the new syntax was, in fact, knee-capped.
- bluehavana 8y agoOne can only ever use Symbols as keys in the 1.9 hash literal syntax, whereas complex objects responding to `#hash` can be used as keys in hash rocket literals.
- chrisseaton 8y ago> I was sad to see => aka "hashrocket" syntax go It hasn't gone - still there as of 2.6.2 and still the only way to create non-symbol keys in a literal.