Skip to content

Instantly share code, notes, and snippets.

@stewsters
Created June 5, 2018 18:12
Show Gist options
  • Save stewsters/d2b55d3ce501a8820bd7687777952aa7 to your computer and use it in GitHub Desktop.
Save stewsters/d2b55d3ce501a8820bd7687777952aa7 to your computer and use it in GitHub Desktop.
Implementing the groovy .times in Kotlin
20.times {
println(it)
}
private fun Int.times(function: (Int) -> Unit) {
for (i in 0 until this) {
function(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment