From: Jason Roelofs Date: 2007-11-14T06:56:15+09:00 Subject: Re: recursion with blocks ------=_Part_2114_1558388.1194990973353 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Nov 13, 2007 4:49 PM, Mike Perham wrote: > I have a tree structure where I want to walk the structure and find a > node based on a name. I'm unclear how to use recursion with blocks such > that I can return the correct node. All code snippets I've seen have > involved using "puts" to print out a node i.e. not returning anything to > the top-level caller. What's the idiomatic Ruby for doing this? How do > I return a value from a block called recursively? > -- > Posted via http://www.ruby-forum.com/. > > A Ruby block is no different from a regular method. The result of the last line of the block is returned unless there's a manual "return" eariler in the code. Jason ------=_Part_2114_1558388.1194990973353--