Hacker News new | past | comments | ask | show | jobs | submit login

"I’m not sure why Ruby doesn’t have named parameters yet (See disclaimer up top on my ignorance), but the language certainly seems alive and active, in that perhaps the next version will?"

Matz stated during his keynote at Rubyconf 2010 that Ruby 2.0 would have proper named parameters for methods, although in practice they will be largely the same as they are now.




Ah, thanks for that. I thought I might have missed them, but the symbols/hash convention is something I'm growing used too.


And 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


I'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.


After 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.


It 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 :(




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: