4 ms·
Ah, thanks for that. I thought I might have missed them, but the symbols/hash convention is something I'm growing used too.
by daviding 16y ago
Ah, thanks for that. I thought I might have missed them, but the symbols/hash convention is something I'm growing used too.
- Andys 16y agoAnd hashes with symbol keys became a bit nicer in 1.9: Account.create(:firstname => 'Bob', :lastname => 'Smith') # old Account.create(firstname: 'Bob', lastname: 'Smith') # new
- regularfry 16y agoI've got to say, that's probably my least favourite of the new syntax changes. It adds a new, context-specific syntax for both symbols and associativity, hiding what's actually going on in the method call, to save 3 characters per parameter. That's a fair cognitive load and backwards-compatibility problem in exchange for a relatively minor typing and readability gain. Maybe I'll get used to it, but it doesn't seem worth the change to me right now.
- ollysb 16y agoIt does seem very much like a kludge to get pseudo named parameters working. It would be great to see this dropped as a hash syntax and used for only named parameters in 2.0. The genie does seem to be out of the bottle though :(
- rbxbx 16y agoAfter using Ruby 1.9.2 for a few months now the new/alternate hash syntax has grown on me quite a bit, especially for keyword arguments. It typically ends up being much more readable (unless your value is a symbol (key: :value) reads awfully). If you don't like it though, there's no reason to use it yet.