Last active
August 17, 2016 22:45
-
-
Save travisdachi/0d35517f24ffa4c6080a8da47f537532 to your computer and use it in GitHub Desktop.
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
for (p in list) println(p) | |
list.forEach { println(it) } | |
// Taken from Kotlin standard library | |
public inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit { | |
for (element in this) action(element) | |
} | |
for (i in 0..list.size - 1) println("list[$i]: ${list[i]}") | |
for (i in list.indices) println("list[$i]: ${list[i]}") | |
list.forEachIndexed { i, present -> println("list[$i]: $present") } | |
// Taken from Kotlin standard library | |
public inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit): Unit { | |
var index = 0 | |
for (item in this) action(index++, item) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment