Create a file named hello.rb
puts "Hello!"
$ ruby hello.rb
$ irb
1.9.3-p194 :001 >
def hello
puts "Hello!"
end
hello
def hello(name)
puts "Hello, #{name}!"
end
hello("Brian")
class Person
end
brian = Person.new
class Person
def initialize
puts "Initialize!"
end
end
class Person
def initialize(name)
puts "Initializing '#{name}'"
end
end
brian = Person.new("Brian")
class Person
def hello
puts "Hello there!"
end
end
brian = Person.new("Brian")
brian.hello
class Employee < Person
end
module Hello
end
module Hello
def hello
puts "Hello!"
end
end
Hello::hello
include Hello
$ gem install pry