From: James Harrison Date: 2010-07-14T01:15:47+09:00 Subject: Re: Ruby garabage collector On Jul 13, 2010, at 10:06 AM 7/13/10, Abder-Rahman Ali wrote: > Thanks a lot James for your clarification. > > Actually, I;m familiar with scoping as I dealt with it in Java, and new > to Ruby, and my point was the garbage collection here. > > So, can I say that "word" in puts "#{word}" after the do-block is > garbage collected since I know more have access to it? > -- > Posted via http://www.ruby-forum.com/. > Java's garbage collected, too. So it's just the same as in there. I imagine you've missed a central feature of Java somewhere ;) The simple difference between garbage collection and non-garbage-collection is what happens when something falls out of scope. In C++, C, other languages that have manual memory management only, you have to free up the RAM assigned to the variable. In Java, Ruby, Python, Perl, those languages, the variable falls out of scope and the interpreter or compiler automatically frees the memory up for you. Go read up on garbage collection. http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) isn't atrocious, but maybe pick up a cheap computer science textbook or something. The relationship you're proposing is essentially correct, though. You no longer have access to "word", so it's garbage collected. The memory associated with it is freed up and your computer goes on living its quiet, binary life, sadly contemplating a time when its memory was full of ones and zeroes in orderly, useful fashion. Best James