From: James Harrison Date: 2010-07-14T00:53:15+09:00 Subject: Re: Ruby garabage collector On Jul 13, 2010, at 9:42 AM 7/13/10, Abder-Rahman Ali wrote: > James Harrison wrote: >> The simplest way to think of it is if something falls out of scope. > > Thanks James. Can you provide a simple Ruby code to clarify the idea. A > bit confusing me still. Sure thing. Sounds like you might be new to programming, yeah? Scope is something you may need to look up to understand a little better. In ruby there are a few scope rules that you should look up and get familiar with, and they changed for 1.9.1 in some small ways (I believe...). The MetaProgramming Ruby book has some great insights into scope, too. Simple, here's an example: words = ["foo", "bam", "bat"] words.each do |word| #here we create a variable called "word" puts "#{word}" #here we print out the contents of the "word" variable end #here we end the block that word was created inside of puts "#{word}" #this will fail, as word does not exist outside of the block word is a variable that is local to the block associated with the .each call on the array. Once the block ends, the variable word stops existing: it "falls out of scope". Go read up on scoping and scope generally, it'll do you good ;) Best James