Created
January 18, 2011 18:06
-
-
Save jacegu/784860 to your computer and use it in GitHub Desktop.
Another example of ruby modules, this time to illustrate static and non static methods inside a module.
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
module ModuleExample | |
def self.hello_world | |
puts 'This is a static hello world from a module' | |
end | |
def hello_world | |
puts 'This is a non static hello world from a module' | |
end | |
end | |
ModuleExample::hello_world | |
begin | |
imposible = ModuleExample.new | |
rescue NoMethodError | |
puts 'You can\'t create an instance of a Module' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment