Thursday, 15 July 2010

Swift functions accepting tuples -



Swift functions accepting tuples -

is possible pass in tuple function long types match up?

when seek it, missing argument in parameter error:

var mytuple = ("text",10,"more text") func myfunction(a:string, b:int, c:string) { // etc... } myfunction(mytuple)

yes, it's possible under these conditions:

the tuple must immutable the number of values in tuple, type, , order must match parameters expected function named parameters must match external names in function signature non-named parameters must match parameters without external name in function signature

so, code ok, thing have turning tuple immutable 1 (i.e. using let , not var):

let mytuple = ("text", 10, "more text") func myfunction(a:string, b:int, c:string) { // etc... } myfunction(mytuple)

one more illustration external names:

let mytuple = ("text", paramb: 10, paramc: "more text") func myfunction(a:string, paramb b:int, paramc c:string) { // etc... } myfunction(mytuple)

swift

No comments:

Post a Comment