Created
January 1, 2017 18:26
-
-
Save Cinderhaze/dc6ecd4d14c2783d6885380d986aedd0 to your computer and use it in GitHub Desktop.
Trying to get started with ruby hello_world.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld | |
def hello() | |
'Hello, World!' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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