Possible Duplicate:
How to run ruby files?
I am starting to learn Ruby and having a hard time running the Ruby classes in the Terminal.
I created a class in the Sublime Text editor, just "hello world". I can compile using ruby hello.rb
,
but how do I execute it?
I went to the terminal in my root directory and typed rails c
which gave me a console. Could some one please tell me how to create an instance? Which console do I use?
Open Interactive Ruby Open up IRB (which stands for Interactive Ruby). If you're using macOS open up Terminal and type irb, then hit enter. If you're using Linux, open up a shell and type irb and hit enter. If you're using Windows, open Interactive Ruby from the Ruby section of your Start Menu.
Ruby is interpreted, so you don't need to worry about a separate compile step. ruby hello.rb
is the execution command.
The standard interactive shell (REPL) is irb
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With