[#863] RDtool-0.5.0 — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>

Hi,

18 messages 1999/10/23
[#864] Re: RDtool-0.5.0 — matz@... (Yukihiro Matsumoto) 1999/10/26

Hi,

[ruby-talk:00874] Re: call with a Proc

From: matz@... (Yukihiro Matsumoto)
Date: 1999-10-28 07:46:24 UTC
List: ruby-talk #874
Hi,

In message "[ruby-talk:00871] call with a Proc"
    on 99/10/28, Clemens Hintze <c.hintze@gmx.net> writes:

|As the methods 'proc', 'lambda' and 'Proc.new' will takes a block, and
|converts it into a 'Proc' instance, they *consume* that block! There
|is no block afterwards!!!

Hmm, that's inaccurate.  Every methods consume the block given to
them.  In this case:

|   b.list(..., Proc.new{ <do something> });

the block { <do something> } is passed to Proc.new only, no other
method invocation receives that block.  An method which is block
unaware is silently ignore block.

In fact, the Proc making methods (proc, lambda, Proc.new) do not
consume the block.  For exapmle,

   def foo
     p lambda
     p lambda
   end
   foo{p 5}

gives

  #<Proc:0x401f0d50>
  #<Proc:0x401f0d14>

that means two distinct Proc object from same block are generated.

                                                        matz.

In This Thread