Skip to content

Instantly share code, notes, and snippets.

@jacegu
Created January 18, 2011 18:06
Show Gist options
  • Save jacegu/784860 to your computer and use it in GitHub Desktop.
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.
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