贝娄是我的 file_open.rb
def File
def self.open_and_process(*args)
f = File.open(*args)
yield f
f.close
end
end
File.open_and_process("testfile", "r") do |file|
while line = file.gets
puts line
end
end
我总是收到的错误是:未定义的方法 `open_and_process' for File:Class (NoMethodError)