[MacRuby-devel] Objective-C-style selectors and define_method
Laurent Sansonetti
lsansonetti at apple.com
Thu Sep 16 18:43:02 PDT 2010
Hi Caio,
On Sep 16, 2010, at 2:00 PM, Caio Chassot wrote:
> Hi,
>
> Can I define Objective-style interspersed-selector methods dynamically with define_method?
>
> I did this:
>
> class Foo
> # def foo(a, bar:b); puts a, b end
> define_method :"foo:bar" do |a, b| puts a, b end
> end
>
> Foo.new.foo(0, bar:1)
>
> and it seems to work. Is that it, or did I miss anything?
Nope, seems good :) I would however pass :"foo:bar:" instead. I believe MacRuby will add the trailing : for you but it's clearer to be explicit here.
Laurent
More information about the MacRuby-devel
mailing list