should I run my first program on “interactive Ruby” or " start command
prombt with ruby"
Interactive Ruby (better known as “irb”) is a special Ruby prompt,
which allows you to input Ruby code, and have it “run” immediately.
While you can use it to run scripts and applications, it’s a bin
cumbersome. So, better to use the Command Prompt with Ruby.
Unless Ruby is in your PATH (if you didn’t change any default settings
in the RubyInstaller, it isn’t, however), where any command prompt
will work.
ok. but I need to open the .rb file an write code in it and then run it
so how can i do it?
A text editor would be the obvious solution. SciTE[0] is a popular
choice in that area.
It can execute Ruby code, too, but you’ll probably have to set that up
within SciTE. Its documentation will explain how to do that, and it is
likely that a search engine will provide specifics for Ruby.
but what about the code which written in the interactive ruby.
is that write in the one file .rb if yes, how can i find it.
No, it’s not stored anywhere, except the .irb-history (if enabled),
which is in your user profile’s root directory. %USERPROFILE% in the
Explorer address bar will take you there.
and if i need to write .rb file containing some code and need to run it
uding my installion to ruby 1.8.7. what can i do?
This is the best way for experimenting with Ruby or testing out some
feature you’ve just learned, as if there’s an error you can just hit
cursor-up and edit/rerun the line.
(2) Open a text editor (even notepad will do), write some ruby in it.
Save it, with extension .rb. Then run it
$ ruby myprog.rb
This will run all the code in the file. This is the best way to write a
larger program.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.