From: Haruka YAGNI Date: 2011-04-01T20:30:10+09:00 Subject: Re: SImple question about file io Hi Paul On Fri, Apr 1, 2011 at 7:21 PM, Paul Joyce wrote: > Adding opf = nil solves the problem, though I must confess to not being > entirely sure why, since the initialisation should create it, and as far > as I can tell it exists for the rest of the runtime, just closes and > re-opens pointing to a different file.  I mean the problem arises in the > line following the File.new statement that defines opf ??? As my code shows, the variables defined in a loop reset with nil on each loop. This is a feature of "local-variable(in-block)". When a variable is defined outside the loop, it is "local-variable" (not in-block). This local-variable is not reseted and works as you expect. To check the type of a variable 'v', try "p defined?(v)". -- Haruka YAGNI