遍历数组
var secondForLoop=0;
for var i=0;i<3;++i{
secondForLoop+=1;
}
println(secondForLoop);
for 循环遍历最大值
let interestingNumbers=[
"prime":[3,5,3,65,33],
"fibonacci":[1,1,5,3,3],
"square":[1,4,2,76,43]
];
var largest=0;
for(kind,numbers)in interestingNumbers{
for number in numbers{
if number>largest{
largest=number;
}
}
}
println(largest);
while循环
var n=2;
while n<100{
n=n*2;
}
println(n);
do-while循环
var m=2;
do{
m=m*2;
}while m<100;
println(m);
...使用
var firstForLoop=0;
for i in 0...100{
firstForLoop+=i;
}
println(firstForLoop);