Syntax
Kotlin For Loop over a Range Syntax
In Kotlin, for loop over a range: loops over a range — for (i in 1..10) {
}
Quick Answer
- Syntax
for (i in 1..10) {
}
KotlinSyntax
For Loop over a Range
Code example
for (i in 1..10) {
}
Loops over a range.
How to for loop over a range in Kotlin
- Open your Kotlin file or editor.
- Copy the example, then replace its sample names and values for your code.
Kotlin For Loop over a Range Syntax
Use for (i in 1..10) {
}.
Related Syntax References
Frequently asked questions
What is the Kotlin syntax for for loop over a range?
Use this pattern: for (i in 1..10) {
}
Can I copy this Kotlin code example?
Yes. Use Copy code and adapt the example to your program.
Is this Kotlin syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify