Skip to content

Instantly share code, notes, and snippets.

@s2k
Created April 12, 2013 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s2k/5375367 to your computer and use it in GitHub Desktop.
Save s2k/5375367 to your computer and use it in GitHub Desktop.
A way to chain class methods
class X
def self.m1
puts "m1 called"
self
end
def self.m2
puts "m2 called"
self
end
end
X.m1
X.m2
puts
X.m1.m2
X.m2.m1
# Produced output:
# m1 called
# m2 called
# m1 called
# m2 called
# m2 called
# m1 called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment