Ruby – A hello world ruby script example

$ cat testscript.rb
#!/usr/bin/env ruby

a_string = "Hello World!"
puts a_string
puts a_string.class

The first line is slightly unusual because:

https://en.wikibooks.org/wiki/Ruby_Programming/Hello_world#Using_env

Next make it an executable:

$ chmod 777 testscript.rb

then run the script:

$ ./testscript.rb
Hello World!
String