0
Can anyone see why this loop isn't breaking at i[2]? Thanks.
4 Answers
+ 4
There is no element having value 2 in <myArray>, your condition `if( i == 2)` never satisfies.
+ 4
We can use ranged for loop
for (index in 0 .. myArray.size)
{
if (index == 2)
{
break
}
println(myArray[index])
}
+ 2
Thank you so much guys!
+ 1
Thank you so much for responding. How do I get it to break when the index == 2?