From: daz Date: 2005-12-09T08:12:36+09:00 Subject: Re: Not initialized Edward Rawde wrote: > So far I've not been able to do this without getting "uninitialized class > variable" errors. Is there a simple way to do it? > I've only been learning Ruby for two days so it's quite possible I've missed > the obvious. > > Ed Hi Ed, (I saw your acknowledgement to Logan) Here's another: ............... FNAME = 'test.bin' class Files @@file = nil @@code = [] @@address = 0 @@offset = 0 def Files.read_file File.open(FNAME, 'rb') do | @@file | while @@address < 65536 and (@@byte = @@file.getc) @@code.push(@@byte) @@address += 1 end end end def Files.readCodeByte(index) @@file or read_file @@code[index-@@offset] end def Files.setOffset(anoffset) @@file or read_file @@offset = anoffset end end daz