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?
编译器显示错误警告。我的语法有什么问题?
2 个解决方案
#1
4
var myArray:(Int,Int)[] = []
myArray.append( 1,1 );
print("myArray =\(myArray)");
The above code works fine
上面的代码工作正常
#2
4
Your tuple doesn't need a second set of parentheses around it. This works fine:
你的元组不需要围绕它的第二组括号。这很好用:
myArray.append( 1,1 );
#1
4
var myArray:(Int,Int)[] = []
myArray.append( 1,1 );
print("myArray =\(myArray)");
The above code works fine
上面的代码工作正常
#2
4
Your tuple doesn't need a second set of parentheses around it. This works fine:
你的元组不需要围绕它的第二组括号。这很好用:
myArray.append( 1,1 );