Created
January 11, 2015 20:04
-
-
Save andrei512/ee4a7c7dd39c9e578901 to your computer and use it in GitHub Desktop.
factory hack
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 { | |
} | |
class B { | |
} | |
var factory: [String:()->(AnyObject)] = [ | |
"A" : { | |
return A() | |
}, | |
"B" : { | |
return B() | |
} | |
] | |
var a: AnyObject = factory["A"]!() | |
var b: AnyObject = factory["B"]!() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment