Last active
October 21, 2015 21:17
-
-
Save potmo/affb2012d6d909787fd4 to your computer and use it in GitHub Desktop.
Instantiating objects from tupels
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
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