Created
June 5, 2018 18:12
-
-
Save stewsters/d2b55d3ce501a8820bd7687777952aa7 to your computer and use it in GitHub Desktop.
Implementing the groovy .times in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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