From: Robert Klemme Date: 2012-10-24T23:16:21+09:00 Subject: Re: Calling a method foo() or an object foo.method_call_here - both On Wed, Oct 24, 2012 at 3:41 PM, Robert Klemme wrote: > On Wed, Oct 24, 2012 at 3:20 PM, Marc Heiler wrote: >> Your example unfortunately requires the leading name >> of the object. This is not what I want, because it >> would require additional typing effort. > > But you cannot use "foo" to denote the object and invoke the method at > the same time. This is simply not possible. > > How about defining a function class: > > class Function > attr_accessor :default > > def call(x = default, *rest) > printf "x=%p rest=%p\n", x, rest > end > end Sorry, this line belongs here: f = Function.new > # or even > > f = Class.new do > attr_accessor :default > > def call(x=default, *rest) > printf "x=%p rest=%p\n", x, rest > end > end.new > > f.call > f.default = 123 > f.call Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/