From: "David A. Black" Date: 2008-06-04T03:27:39+09:00 Subject: Re: Beginner help Hi -- On Wed, 4 Jun 2008, Justin To wrote: > Hello, I have just started learning Ruby and have already come upon a > problem: > > i'm learning and blocks and procs: > > def meth(proc) > puts "before proc" > proc.call > puts "after proc" > > yield("hi") > > if block_given? If there's no block, that yield is going to have caused an exception anyway. > puts "block exists" > else puts "D.N.E." > end > end > > meth proc {|var1| puts "block" } > > prc = lambda do > puts "inside proc" > end > > meth(prc) > > the main thing i don't understand is how to create a block when the > original method has an argument? and the block takes an argument.... > > def meth(proc) > > meth proc {|var1| puts "block" } meth(proc) {|var1| puts "block" } Is that what you mean? David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!