From: Dave Goodchild Date: 2008-08-30T06:20:54+09:00 Subject: Re: Writing a method to handle a code block? ------=_Part_23398_1222080.1220045146786 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline As far as I understand it, passing a parameter to a method prefixed with &, or the return value of 'lambda', creates or passes in a Proc object which can continue to be called after the original function call has gone out of scope i.e. a closure. Yield by contrast is a way of communicating with a code block inside a method, and the block can talk back. More useful in iterations, transactions and so on. On Fri, Aug 29, 2008 at 10:14 PM, Brian Ross wrote: > Thank you, everyone. If I understand correctly: > > &foo just means that whatever is passed to it (& requires a code block) > will > be saved as a local variable that may be used later. > > The call method executes the block that it acts on and then executes it but > first assigns ttiuohe block's | block argument | to the parameter passed to > it. > > Is it then that yield functions the same as the call method? I haven't > quite > gotten to proc objects yet, but it looks like using & converts the code > block into an object, but yield, strictly, doesn't? Are code blocks the > exception to the "everything in ruby is an object" rule? > > I'm certainly understanding this far better than I was previously, I think. > > Brian > ------=_Part_23398_1222080.1220045146786--