From: jeff_alexander_44@... Date: 2007-03-24T23:45:05+09:00 Subject: scope and RAII 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? I am interested in using ruby for some resource-intensive tasks. In the above example, imagine Array replaced with some resource-tied class written in C, for example a set of hardware textures. Does ruby make a special effort to release a variable when it goes out of scope? The canonical example is File.open("foo.txt") { |f| print f.read } # internal file handle released here Is this behavior a general rule, or just a special case for File.open()? And is it released immediately or upon the next GC pass? Thanks, Jeff