"Alvaro Perez" <alvaro.pmartinez / gmail.com> wrote in message news:1a42f3dc9ed549e04ba4199668039da6 / ruby-forum.com... > > It's the only way that works so far. I need to explore inside the > children and break when I found the correct item or return nil. If it > were a local variable, when I break the loop it continues on the next > level of the tree (and then it would always return nil). Did my examples not work at all? I thought that, at worst, they'd have some bugs that would be easily ironed out... My throw example, if throw works the way I think it does, definitely doesn't continue the recursion. Throw is the non-exception exception. My non-throw exception should also cease the recursion, without the need for a non-stack variable. The recursive function examines the return value of the recursive call, ceases the search if something is found and passes this back down the stack. That's all you have to do to cease the search: pass the found item from one recursive call to the other. This unrolls the stack just as an exception would. Does this really not work?