when i run my ruby file
ruby test.rb
which has one line:
IO.write("testfile.txt","123")
i get
test.rb:1:in `<main>': undefined method `write' for IO:Class (NoMethodError)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, what kind of answer do you expect?
IOdoes not have any class method calledwrite. At most it hasbinwriteand an instance method#write.So either you use
binwrite(http://rubydoc.info/stdlib/core/1.9.3/IO.binwrite) or you use theFileclass and go the full way ofEdit: Apparently there is an
IO.writemethod beginning with Ruby 1.9.3. There is, however, no such method in any earlier versions of 1.9 or 1.8.