I have the array:
var myArray:[(Int,Int)] = []
But when I add value to it by:
myArray.append((1,2))
The compiler show mistake warning. What is wrong with my syntax?
Types in Swift fall into one of two categories: first, “value types”, where each instance keeps a unique copy of its data, usually defined as a struct, enum, or tuple. The second, “reference types”, where instances share a single copy of the data, and the type is usually defined as a class.
var myArray:(Int,Int)[] = []
myArray.append( 1,1 );
print("myArray =\(myArray)");
The above code works fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With