Scala lists use zero-based indexing. Access an element by writing the index in parentheses.
val ages = List(14, 32, 50, 21)
println(ages(0)) // 14
println(ages(2)) // 50
Assignment
Follow the Coding Tutorial and access elements from the list.
Hint
The first element is at index 0.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check