From: Jacob Fugal Date: 2006-02-03T04:51:46+09:00 Subject: Re: Chomping and stomping On 2/2/06, William James wrote: > ara.t.howard@noaa.gov wrote: > > harp:~ > ruby a.rb < /dev/null > > a.rb:3:in `chomper': private method `chomp' called for nil:NilClass (NoMethodError) > > from a.rb:9 > > The error I get in a dos-box is > The system cannot find the path specified. > > To produce the error you gave, I must do it this way: > ruby a.rb < nul: > > When you post something that depends upon a particular > operating system, you need to make that dependency clear. Well, in Ara's defense I would claim that prefixing the command with "harp:~ >" and using "/dev/null" both should be clear indicators that he's talking about a *nix system. > It is reasonable to write a program that requires input. > It is not reasonable to expect a program that requires input to > function properly when you deliberately deprive it of input. This problem is not only due to no input. The same error will arise if you reach EOF before matching the expected line. Try this: > echo "Hello" | ruby a.rb It *is* reasonable to expect a program that requires input to function properly when invalid input is provided. Maybe the proper action is to raise an error, but it should be a contextually appropriate error. Jacob Fugal