From: Alex Young Date: 2007-03-25T01:08:42+09:00 Subject: Re: scope and RAII Alex Young wrote: > jeff_alexander_44@yahoo.com wrote: >> def scope(*args) >> yield(*args) >> end >> >> scope(Array.new) { |array| >> array.push 1 >> array.push 7 >> array.push 11 >> puts array.join(",") >> } >> # here the variable 'array' is gone -- is it deallocated? > No. In general, it won't be deallocated until the next GC pass. I should have pointed out here (in case you hadn't spotted it already) that the variable is utterly distinct from the object to which it refers. The variable can go out of scope and the object may not be collected at all - it entirely depends on what else has a reference to that object. Hope that's clear, -- Alex