0
What is wrong?
fun main(args: Array<String>) { val n = arrayof(4,6,7,0,8) for(n in 8) // if for(8 in n) this is also show error {println("yes")} }
2 Respuestas
+ 2
You should write :
for (i in n) {
if (i == 8) {
println("Yes")
}
}
Explanation:
First, i = 4. Then check it with IF statement. But it isnt equal to 8. So iteration will be continued.
Second, i = 6. It also continued.
....
Last, i = 8. Then check it and the result is TRUE. Because it is true, it will be printed.
0
Thanks