From: Robert Klemme Date: 2004-06-28T20:38:01+09:00 Subject: Re: (oddity) applying objects with #call() implicitly "gabriele renzi" schrieb im Newsbeitrag news:f6pvd0ldf65contvqdldtjq5hjcracc0tq@4ax.com... > Hi gurus and nubys, > > lurking comp.lang.misc, I noticed this message: > http://tinyurl.com/2q8c7 > > and suddenly had the vision to have that in ruby too. > What I'm talking about is application of callable objects. > As of now we have to explicitly write: > > callable.call arg1, arg2 > > and it feels ugly. > > I was going to ask if we could have this: > callable arg1,arg2 # implicitly looks for #call > callable # the callable object > callable() # forces application with zero arguments > ... > > what's wrong with this? Ambiguity. "callable arg1,arg2" denotes an invocation of the method "callable" of "self". "callable()" also invokes the same method albeit without arguments. However, you can use #[] like this: >> callable = lambda {|*args| puts "Seen #{args.inspect}"} => # >> callable[ "foo", "bar" ] Seen ["foo", "bar"] => nil Regards robert