From: Corey Konrad <0011@...> Date: 2007-03-17T07:36:21+09:00 Subject: Re: yield Brian Candler wrote: > On Sat, Mar 17, 2007 at 07:10:26AM +0900, Corey Konrad wrote: >> >> def printer(arg) >> yield arg >> end >> >> printer("ball") >> printer {|word| puts word} >> >> why is that, cant yield be used with arguments? > > It can. Your second function 'printer' takes one argument plus one > block. > However in the first case you were calling it without a block, and in > the > second case you were calling it without an argument. > > What you need is: > > printer("ball") {|word| puts word} oh ok, my understanding for some reason was that the method was going to remmeber that i set arg to "ball" so that when i used printer with the block that "ball" would still be in arg. So is that why it isnt working, is because when i call the printer method the second time the value stored in arg is destroyed? -- Posted via http://www.ruby-forum.com/.