From: Lloyd Linklater Date: 2008-11-05T23:10:13+09:00 Subject: Re: what's wrong about this chomp code? Zhenning Guan wrote: > when I was running this code > ------------ > File.open("1c.txt") do |f| > while line= f.gets.chomp; > p line ; > end > end > ------------- > > why they warning with the message below? > > ========= > private method 'chomp' called for nil:NilClass > from ok.rb:2:in 'open' > from ok.rb:2 > ========== This might be easier: File.open('1c.txt').each { |line| puts line.chomp } -- Posted via http://www.ruby-forum.com/.