Skip to content

Instantly share code, notes, and snippets.

@Cinderhaze
Created January 1, 2017 18:26
Show Gist options
  • Save Cinderhaze/dc6ecd4d14c2783d6885380d986aedd0 to your computer and use it in GitHub Desktop.
Save Cinderhaze/dc6ecd4d14c2783d6885380d986aedd0 to your computer and use it in GitHub Desktop.
Trying to get started with ruby hello_world.
class HelloWorld
def hello()
'Hello, World!'
end
end
$ irb
2.3.0 :001 > require_relative 'hello_world'
=> true
2.3.0 :002 > HelloWorld.instance_methods(false)
=> [:hello]
2.3.0 :003 > HelloWorld.hello
NoMethodError: undefined method `hello' for HelloWorld:Class
from (irb):3
from /home/dawiest/.rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
2.3.0 :004 > hw = HelloWorld.new
=> #<HelloWorld:0x000000028ee750>
2.3.0 :005 > hw.hello
=> "Hello, World!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment