So what you were trying to do was:
$ irb
001 > ruby ex1.rb
The ruby
command is a program on its own, so you should use ruby
directly from the command line like this:
$ ruby ex1.rb
This means “Ruby, please execute this file”, whereas irb
is a REPL, awaiting Ruby statements directly. This means you could type your Ruby code directly into irb like this:
$ irb
001 > puts "Hello, world!"
Hello, world!
Or you could go into irb
and load the contents of the file and then experiment with the code:
$ irb
001 > require './ex1'