抱歉这个愚蠢的问题我是红宝石新手。下面的代码有什么问题导致此错误:
private method `gets' called for "file.txt":String (NoMethodError)
这是代码:
def read_file(path)
File.open(path, 'r') do |file|
while line = path.gets
puts line
end
end
end
def initialize
read_file("file.txt")
end