Make repeat example more expressive
This commit adds the zero-based index of current iteration from the passed HOF "action" of the repeat function to its associated code sample. KT-20357
This commit is contained in:
@@ -15,9 +15,14 @@ class ControlFlow {
|
||||
repeat(3) {
|
||||
println("Hello")
|
||||
}
|
||||
|
||||
// greets with an index
|
||||
repeat(3) { index ->
|
||||
println("Hello with index $index")
|
||||
}
|
||||
|
||||
repeat(0) {
|
||||
error("We should not get here!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user