Skip to content

Instantly share code, notes, and snippets.

@tocttou
Created December 12, 2017 13:10
Show Gist options
  • Save tocttou/daf4eb604bc9923b502813cadbc98678 to your computer and use it in GitHub Desktop.
Save tocttou/daf4eb604bc9923b502813cadbc98678 to your computer and use it in GitHub Desktop.
package utils
fun oldFor(
initialSetter: () -> Int,
limitingCondition: (Int) -> Boolean,
updater: (Int) -> Int,
codeBlock: (Int) -> Unit) {
var i = initialSetter()
while (limitingCondition(i)) {
codeBlock(i)
i = updater(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment