On Wed, Oct 24, 2012 at 3:41 PM, Robert Klemme
<[email protected]> wrote:
> On Wed, Oct 24, 2012 at 3:20 PM, Marc Heiler <[email protected]> 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/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to