In Swift you can ignore the loop constant by using _ like so:
for _ in 0...10 {
//loop logic here
}
Is there an equivalent in Kotlin?
You can also use repeat() function:
repeat(10){
//loop logic here
}
You can just use a forEach loop, and don't use it inside the closure:
(1..10).forEach {
println("hello")
}
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