From 88f508446adb7ed1895313f225170b39096b6bbc Mon Sep 17 00:00:00 2001 From: Julian Kotrba Date: Mon, 3 Aug 2020 23:48:06 +0200 Subject: [PATCH] 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 --- libraries/stdlib/samples/test/samples/misc/controlFlow.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/samples/test/samples/misc/controlFlow.kt b/libraries/stdlib/samples/test/samples/misc/controlFlow.kt index d613d0bfb28..484faf64542 100644 --- a/libraries/stdlib/samples/test/samples/misc/controlFlow.kt +++ b/libraries/stdlib/samples/test/samples/misc/controlFlow.kt @@ -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!") } } -} \ No newline at end of file +}