From: christopher.j.meisenzahl@... Date: 2002-11-16T05:05:26+09:00 Subject: Re: Simple Newbie IO question. I'm pretty new to Ruby but I'm willing to bet that there are some things that IRB won't handle well. IO streams may be one of them. Can anyone else expand on this one? Christopher J. Meisenzahl CPS, CSTE Senior Software Testing Consultant Spherion christopher.j.meisenzahl@citicorp.com > -----Original Message----- > From: montana [mailto:montana@buc99.bsd.st] > Sent: Friday, November 15, 2002 2:21 PM > To: ruby-talk > Cc: montana > Subject: Simple Newbie IO question. > > > Hi Everyone- > > I'm reading the "Pick-axe" book. In the chapter on IO it > discusses File.open. > > Straight from the book: > File.open("testfile", "r") do |aFile| > > # ... process the file > > end > > 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?? > > What is the correct way to pass a string to a file and then > open that file again to read it? > > Thanks. > SA > >