Deleting objects?

Hello,

My little program works one. However fails when I add a loop two run it
multiple times with different input data.

I believe this might be due to objects that have not been delete. Is
there a
way to delete objects other than setting the variable to nil?

-Bernd

On Thu, 16 Feb 2006, Paatsch, Bernd wrote:

My little program works one. However fails when I add a loop two run it
multiple times with different input data.

I believe this might be due to objects that have not been delete. Is there a
way to delete objects other than setting the variable to nil?

Example…

$global_var = {}

def my_func( line)

Uses $global_var, $global_var just accumulates objects, never

letting

go.

end

STDIN.each_line do |line|
my_func( line)
end

Now if we use a local variable like so…

def my_func( line)
local_var = {}

We get a fresh new hash every loop, old hash and old objects we

held

on to are garbage collected automagically every time we leave the

scope of the variable.

end

To really debug your problem we need to see your code.

John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand

Carter’s Clarification of Murphy’s Law.

“Things only ever go right so that they may go more spectacularly wrong
later.”

From this principle, all of life and physics may be deduced.