Star Development Corporation
"Every man and every woman is a star" -- Liber AL vel Legis 1.3
Chapter 1: The Basics
Let's start out with the classic program, HelloWorld.
HelloWorld.rb
puts 'Hello, world!'
=> Hello, world!
Next, add a line to indicate to the shell that you are running a Ruby program.
The #! at the beginning of the line is called a shebang. It works in both *nix and Windows.
The -w means that you are asking the Ruby interpreter to give you warnings of non-standard usage
before running your program.
#!/usr/bin/env ruby -w puts 'Hello, world!'
=> Hello, world!
Now, let's put the hello statement into a method.
#!/usr/bin/env ruby -w def hello(name) puts 'Hello, ' + name + '!' end name = 'world' hello(name)
HelloClass.rb
#!/usr/bin/env ruby -w class Greetings def hello(name) puts 'Hello, ' + name + '!' end end g = Greetings.new g.hello('world')