On 13-07-2010 17:30, Abder-Rahman Ali wrote:
> In the "Why's poignant guide to Ruby" book, it states the following:
> 
> "If you can't get to an object through a variable, then Ruby will figure
> you are done with it and will get rid of it. Periodically, Ruby sends
> out its garbage collector to set these objects free."
> 
> The point I'm not getting here is: "If you can't get to an object
> through a variable..."
> 
> Can you provide an examples that illustrates this?
> 
> Thanks.

a = [1,2,3].find {|x| x > 3}

puts a


In this (maybe too simple) example, x is garbage-collected once flow
leaves the block.


--
http://iruel.net