[Rubycocoa-devel 298] Re: message dispatch syntaxes

Zurück zum Archiv-Index

Jonathan Paisley jp-ww****@dcs*****
Tue Jun 20 02:22:17 JST 2006


>
> Imagine you have this in Objective-C:
>
> 	[MyClass +foo]
> 	[MyClass +foo:(id)foo]
>
> If in Ruby you call:
>
> 	MyClass.foo()
>
> Which method will it call, as passing nil is supported?

I'm confused - I don't think we assume anywhere that omitting an  
argument is the same as passing nil.

In other words, MyClass.foo() should never call the foo: method,  
because that would involve assuming that you want to pass nil. We  
have not given any arguments, therefore it can only call an objc  
method that takes no arguments.

The point you made in your first message about exploded arrays also  
doesn't appear to apply, because an exploded empty array is  
equivalent to a method call with no arguments.

i.e.,
    x.foo(*[])
is the same as
    x.foo()
(I think).

Forgive me if I've got the wrong end of the stick here..

Jonathan





More information about the Rubycocoa-devel mailing list
Zurück zum Archiv-Index