Foundations
Lists
Lists keep related values in order and let code read them by index.
Lists
Lists.kt
fun main() {
val scores = listOf(82, 91, 76)
val bonus =
val firstScore = scores[0]
val adjustedScore = scores[1] + bonus
println("first=$firstScore")
println("adjusted=$adjustedScore")
}
fun main() {
val scores = listOf(82, 91, 76)
val bonus =
val firstScore = scores[0]
val adjustedScore = scores[1] + bonus
println("first=$firstScore")
println("adjusted=$adjustedScore")
}
fun main() {
val scores = listOf(82, 91, 76)
val bonus =
val firstScore = scores[0]
val adjustedScore = scores[1] + bonus
println("first=$firstScore")
println("adjusted=$adjustedScore")
}
list index
List indexes start at zero, so `scores[0]` reads the first value.