Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created January 11, 2015 20:04
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 andrei512/ee4a7c7dd39c9e578901 to your computer and use it in GitHub Desktop.
Save andrei512/ee4a7c7dd39c9e578901 to your computer and use it in GitHub Desktop.
factory hack
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