From: 7stud -- Date: 2009-07-23T10:24:59+09:00 Subject: Re: why I get an empty hash? 7stud -- wrote: > 7stud -- wrote: >> >> So you see, the result is the same. It doesn't matter what you do to >> the hash returned by the recursive method calls because you don't do >> anyting with the returned hash, so ruby discards it. >> > > Your question is like asking why the result of calling this method: > > def meth > h = {} > {"AA" => 0} > > return h > end > > p meth > > > is an empty hash. Which is equivalent to asking why the result of calling meth1 below is an empty hash: def meth1 h = {} meth2 return h end def meth2 h = {"AA" => 0} return h end p meth1 Method calls are replaced in your code by the return value of the method. So calling meth1 results in this: h = {} {'AA' => 0} #from meth2 return h -- Posted via http://www.ruby-forum.com/.