On a Mac, you can run three different methods from the terminal. Method 1 In the irb (Interactive Ruby Shell) terminal to execute line by line, then close the command to exit irb.
Method 2 Since ruby is an interpreted language, we can run one command on the terminal
- Save the text editor code with the extension .rb.
- Change the directory in the terminal with the cd command (cd drag the folder to the terminal so that you can be redirected to the directory).
- ruby hello.rb
Method 3 ruby -v know the ruby version ruby -e 'puts WVU' #line on a line in the terminal
source share