From: Robert Klemme Date: 2004-08-05T21:01:27+09:00 Subject: Re: Macros in Ruby "Mauricio Fern�ndez" schrieb im Newsbeitrag news:20040805113529.GA14601@student.ei.uni-stuttgart.de... > On Thu, Aug 05, 2004 at 07:16:29PM +0900, Robert Klemme wrote: > > > - Argument passing, a block isn't strict about the arguments > > > it gets passed, (i.e. it can take any argument). A Proc > > > object in contrast is strict (like methods). The reason I > > > can think of is that it is often usefull not to get all arguments > > > in a block, i.e. 3.times{ puts "Hi, world!" } > > > > I don't know what exactly you mean by this. Argument passing is the same > > for blocks and procs IMHO. Can you explain the difference? > > >> def foo; yield 1,2 end; foo { |a,b,c,d| } > => nil > >> lambda{|a,b,c,d|}.call 1, 2 > ArgumentError: wrong number of arguments (2 for 4) > from (irb):2 > from (irb):2:in `call' > from (irb):2 > >> Proc.new{|a,b,c,d|}.call 1, 2 > => nil > >> RUBY_VERSION > => "1.8.2" > >> RUBY_RELEASE_DATE > => "2004-07-30" Thanks! Also: irb(main):001:0> def foo(&b) b.call 1,2 end => nil irb(main):002:0> foo {|a,b,c,d|} => nil robert