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 <nomethoderror>
> 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/.