Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:42:12+00:00 2026-05-27T01:42:12+00:00

when i run my ruby file ruby test.rb which has one line: IO.write(testfile.txt,123) i

  • 0

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:42:13+00:00Added an answer on May 27, 2026 at 1:42 am

    Well, what kind of answer do you expect? IO does not have any class method called write. At most it has binwrite and an instance method #write.

    So either you use binwrite (http://rubydoc.info/stdlib/core/1.9.3/IO.binwrite) or you use the File class and go the full way of

    File.open("testfile.txt", "w") { |f| f << "123" }
    

    Edit: Apparently there is an IO.write method beginning with Ruby 1.9.3. There is, however, no such method in any earlier versions of 1.9 or 1.8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cron job to run a Ruby script, which runs fine on
I want to run a standalone ruby script in which I need my RoR
I am trying to get Hudson to run my ruby based selenium tests. I
When I run rspec spec I get the following: /usr/local/lib/ruby/gems/1.9.1/gems/rspec-rails-2.7.0/lib/rspec/rails/extensions/active_record/base.rb:26:in `': uninitialized constant ActiveModel
I want my Ruby Script File to run as executable from any directory of
I'm following this tutorial (seems good) for Rails. After I run ruby script/generate scaffold
I want to run my ruby script x times a day (the number might
Is it possible to run a ruby application as a Windows Service? I see
I want to be able to run unstrusted ruby code. I want to be
On windows, I can run my ruby script like this: > ruby myscript.rb but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.