From: Joel VanderWerf Date: 2007-07-17T10:02:41+09:00 Subject: Re: How to reclaim memory without GC.start Travis D Warlick Jr wrote: > Lionel Bouton wrote: >> Actually, as variable affectation is done by reference > > I knew that... woops... **beats head on keyboard** > > However, A chance to redeem myself: I remembered that IO#read returns a > string, so change the while to: > > while buffer[0...512] = file.read(512) > > That should overwrite the contents of the buffer Do you mean file.read(512, buffer) ? ---------------------------------------------------------------- IO#read ios.read([length [, buffer]]) => string, buffer, or nil ------------------------------------------------------------------------ Reads at most length bytes from the I/O stream, or to the end of file if length is omitted or is nil. length must be a non-negative integer or nil. If the optional buffer argument is present, it must reference a String, which will receive the data. At end of file, it returns nil or "" depend on length. ios.read() and ios.read(nil) returns "". ios.read(positive-integer) returns nil. f = File.new("testfile") f.read(16) #=> "This is line one" -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407