Skip to content

Instantly share code, notes, and snippets.

@josinSbazin
Created August 17, 2018 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josinSbazin/d4da46b0588e731be8e94a407b762375 to your computer and use it in GitHub Desktop.
Save josinSbazin/d4da46b0588e731be8e94a407b762375 to your computer and use it in GitHub Desktop.
Kotlin Fast For Each
inline fun <reified T> List<T>.foreach(crossinline action: (T)
-> Unit): Unit {
val size = size
var i = 0
while (i < size) {
action(get(i))
i++
}
}
list.foreach { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment