Created
February 22, 2012 19:17
-
-
Save shepmaster/1886730 to your computer and use it in GitHub Desktop.
Overriding #new
This file contains 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
class A | |
def self.new(arg1, arg2) | |
B.new(arg2, arg1) | |
end | |
end | |
class B | |
def initialize(alpha, beta) | |
puts "#{alpha}, #{beta}" | |
end | |
end | |
a = A.new(1, 2) | |
# => 2, 1 | |
puts a.class | |
# => B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment