i have function returns multiple values in way:
func foo() -> (int, int) { // code return (x, y) }
now in class calling function:
class myclass { private var myx : int! private var myy : int! func myfunc() { let ret = foo() myx = ret.0 myy = ret.1 } }
if set them this
(myx, myy) = foo()
the compiler shows error
cannot express tuple conversion '(int, int)' '(int?, int?) ...
is there way set myx
& myy
directly in case?
are sure that's message? when try code get
cannot express tuple conversion '(int, int)' '(int!, int!)'
this makes sense, since myx , myy implicitly unwrapped optionals. changing foo following works fine:
func foo() -> (int!, int!) { let x = 1 let y = 2 return (x, y) }
Comments
Post a Comment