Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9d6046

Browse files
committed
fix: val to var for mutable value
In the example the variable `x` is mutated with `x++` and should therefore be a declared as a `var` as opposed to an imnmutable `val`.
1 parent 750cbad commit d9d6046

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

08-loops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ for ((index, value) in names.withIndex()) {
6060
The `while` loop is similar to Python (but keep in mind that the condition must be an actual boolean expression, as there's no concept of truthy or falsy values).
6161

6262
```kotlin
63-
val x = 0
63+
var x = 0
6464
while (x < 10) {
6565
println(x)
6666
x++ // Same as x += 1

0 commit comments

Comments
 (0)