Differences between Keyword Arguments in Ruby 2.0 and Interleaved method
signatures in Objective-C
I've been playing with MacRuby, and noticing how it extends Ruby to be
able to handle the Smalltalk-like method (or message) signatures of
Objective-C. At first glance, I thought that it looked a lot like the new
Keyword Arguments of Ruby 2.0, but further inspection shows that they work
in a fundamentally different way.
My first clue was when reading the MacRuby method spec on GitHub.
it "can have multiple arguments with the same name" do
def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
@o.should have_method(:'doSomething:withObject:withObject:')
@o.should_not have_method(:'doSomething')
end
As far as I know, that behavior is not allowed in Ruby 2.0, because the
withObject: part would be used as the sole identifier for the parameter,
and therefore there could not be two with the same name.
Is this an insurmountable problem? Will MacRuby be forced to remain with
Ruby 1.9 because of this?
No comments:
Post a Comment