Skip to content

Instantly share code, notes, and snippets.

@potmo
Last active October 21, 2015 21:17
Show Gist options
  • Save potmo/affb2012d6d909787fd4 to your computer and use it in GitHub Desktop.
Save potmo/affb2012d6d909787fd4 to your computer and use it in GitHub Desktop.
Instantiating objects from tupels
struct Test {
let a:String
let b:Int
init(a:String, b:Int){
self.a = a
self.b = b
}
}
let f = Test.init
f
let s = f(a: "kaka", b: 123)
let m = ("kokoa", 123)
let arr = [("jabba", 666)]
let things = arr.map(f)
things[0].a
func create<T,K>(input: K, initi: (K)->T )->T{
return initi(input)
}
let q = create(("kossa", 666), initi: Test.init)
q.a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment