Skip to content

Instantly share code, notes, and snippets.

@sortega
Created March 23, 2017 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sortega/0b266fe7e6ea3c68b0472f3a8135e4c6 to your computer and use it in GitHub Desktop.
Save sortega/0b266fe7e6ea3c68b0472f3a8135e4c6 to your computer and use it in GitHub Desktop.
Static methods and modules
> ruby statics.rb
4
statics.rb:12:in `<main>': undefined method `non_static' for Foo:Module (NoMethodError)
module Foo
def non_static(x)
x * x
end
def self.static(x)
x * x
end
end
puts Foo.static(2)
puts Foo.non_static(4)
@apoloval
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment