From: Bruce Williams Date: 2002-11-16T04:28:51+09:00 Subject: Re: Simple Newbie IO question. On Friday 15 November 2002 02:20 pm, montana wrote: > I tried something similar in irb: > irb(main):001:0> File.open("testfile", "w") do |aFIle| > irb(main):002:1* aFile << "Hello,\nWorld!" > irb(main):003:1> end > NameError: undefined local variable or method `aFile' for > # from (irb):2 > from (irb):1:in `open' > from (irb):1 > > What am I doing wrong here?? > You misspelled |aFile| > What is the correct way to pass a string to a file and then open that file > again to read it? > If you mean write a string to a file, close and reopen to read it, it could be done: File::open('afile', 'w'){ |file| file << aString } # sometime later... var = File::open('afile'){ |file| file.read } -- =================== Bruce R. Williams