From: Charles Oliver Nutter Date: 2011-01-31T06:53:47+09:00 Subject: Re: why is overloading invalid in ruby. On Sat, Jan 29, 2011 at 12:37 AM, Eric Christopherson wrote: > Specifically, MacRuby has an extension to the usual hash parameters > that seems pretty complicated to me, but allows it to interact fairly > painlessly with Objective-C*. It basically allows you to define a > method with named parameters. It's bewildering because a method > invocation like "person.setFirstName('Gloria', { :lastName=>'Alvarez' > })" actually calls a *different* method from > "person.setFirstName('Gloria', lastName: 'Alvarez')" (the former is > the regular Ruby hash argument type; the latter uses the > MacRuby-specific keyed arguments. If no keyed-argument version of a > method exists, it will just translate it into a hash-argument form.) Laurent can correct me if I'm wrong, but I don't think ObjC's syntax qualifies as true named arguments. In MacRuby/ObjC, a method call like foo(bar:1, baz:2) Is just a way of saying something like foo_with_bar_with_baz(1, 2) The method name and the argument names actually resolve to different method bodies internally. In addition, the order is absolutely crucial. The following two calls are not the same and will not end up in the same target method: foo(bar: 1, baz: 2) foo(baz: 2, bar: 1) Named arguments would allow you to call the *same* method with different groups of names in any order. - Charlie