ios - Tuple containing an array (and assigned as variable) not working? -
i trying create array of tuples in swift each tuple contains (1)letter , (2)array of custom objects, when try append throws error 'int' not convertible 't'.
here simplified code:
var tuples : [(letter : character , objects : [myobject])] = [] //this works tuples.append(letter:"test".firstchar(), objects: [myobject(), myobject()]) //gives error => 'int' not convertable 't' on append function var arrayofobjects : [myobject] = [] tuples.append(letter:"test".firstchar(), objects: arrayofobjects)
this should work:
let arrayofobjects : [myobject] = [] tuples.append(letter:"t", objects: arrayofobjects)
as can see, arrayofobjects
constant. problem here might stem fact append
expects constant parameter t
, while passing tuple containing var
. imho makes append
goes little crazy, , compiler gives crazier error description ;-)
Comments
Post a Comment