From: James B Crigler Date: 2004-10-06T03:04:51+09:00 Subject: Re: Table-driven dispatch James B Crigler wrote: > > Robert Klemme wrote: > > > > if File.exists? path > > > File.open(path).each do |line| > > > @text.push line.chomp > > > end > > > > Btw, you don't close the file handle properly here. > > Unless something has changed in 1.8, Pickaxe1 says: > > With no associated block, open is a synonym for File.new . If > the optional code block is given, it will be passed file as > an argument, and the file will automatically be closed when > the block terminates. In this instance, File.open returns nil. > > I'm still looking at the rest of your solution. I'll get back to > the newsgroup soon. I apologize for my previous post. It occurred to me that Robert might be right, and of course he is. There isn't a form for self-closing files unless I add it (per Pickaxe1). Sorry. FWIW, the correct form would be File.open(path) { |file| file.each do |line| @text.push line.chomp end end I.e., I need another level of nesting. -- James B Crigler Voice: (770)494-2077 C-27J Software Requirements Manager Fax: (770)494-3886 Lockheed Martin Aeronautics Company D/6B3M Z/0100 86 South Cobb Drive Marietta GA 30063 "I say, Jerry! You'd be in a Blazing bad way if recalling to life was to become the fashion, Jerry!" -- A Tale of Two Cities