Ruby IRB command errors Windows 10 64bit

Hi I am new to ruby. Just begun Learning it. I am using windows 10 64
bit. I created a file first_script.rb in one folder using atom text
editor. But when I run that file using ruby command in irb it gives
error “undefined local variable or method ‘first_script’ for main:object
from (irb):3”

What is this message about. What is wrong with my file or my command.
Kindly help. I attached the screenshot of the IRB command prompt.

Thanks

First, there is no method in “Ruby”, which would be called ‘ruby’. This
can be understood from the error message: “undefined method ‘ruby’”.

If you want to simply execute your Ruby file, don’t use irb. It’s the
wrong tool for the task. Instead, execute it from the Windows command
line by typing

ruby first_script.rb

(A note aside: If you really insist, you can run a ruby script also
from inside irb. This would be done by

system(‘ruby first_script.rb’)

. In your particular case, I don’t see the advantage of doing this).

The main purpose of irb is interactively executing Ruby commands, not
running Ruby programs…

Thanks Ronald F… I was required run ruby outside IRB. I corrected
my mistake.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs