2 ms·
A bit of history: this syntax originally appeared in MacRuby and is used for the named parameters needed to call ObjectiveC methods: person.setFirstName(fi
by Argorak 15y ago
A bit of history: this syntax originally appeared in MacRuby and is used for the named parameters needed to call ObjectiveC methods:
person.setFirstName(first, lastName: last)
So, introducing it into Ruby 1.9 gave MacRuby the ability of hooking into valid ruby syntax to do its special thing.
As a wild speculation, it may also be used for named parameters, should they ever be introduced in Ruby.
Personally, i like it for exactly that case. I do not like it as a generic hash syntax for another reason: its easy to align the =>, but its hard to align the:.