Skip to content

Instantly share code, notes, and snippets.

@preslavrachev
Created September 9, 2011 07:00
Show Gist options
  • Save preslavrachev/1205644 to your computer and use it in GitHub Desktop.
Save preslavrachev/1205644 to your computer and use it in GitHub Desktop.
Defining class methods in Ruby
class MyClass
# All of these are equivalent
def self.myMethod
true
end
def MyClass.myMethod
true
end
class << self
def myMethod
true
end
end
class << MyClass
def myMethod
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment