On Fri, Jun 16, 2006 at 01:51:23PM +1000, O Plameras wrote: > Matthew Palmer wrote: > > >It increases complexity, and unnecessary code will also confuse in the > >future since a programmer will look at that and think "I think that's > >unnecessary, but perhaps there's something special this time that needs > >it". > > It's special this time here: > > #!/usr/bin/env ruby > while not $stdin.eof do > puts $stdin.readline > end
Sure, but why in the name of all that is holy would you do that? If you expect to be dealing with a lot of input and don't want to kill your machine, you'd do something like: $stdin.each_line { |l| puts l } In short, I've written several thousand lines of Ruby, a fair amount of it dealing with IO processing, and I've never once yet used IO#eof -- nor do I ever intend on doing so. The iterators available in the IO class can take care of basically anything you need to do. > and here: > > #!/usr/bin/env ruby > puts $stdin.readline while not $stdin.eof Totally equivalent to your example above. - Matt _______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders