Start learning free

LESSON 95 OF 348 · ARRAYS I

List Size in Scala in Scala

Lesson

We can get the number of elements in a Scala List using .size.

val ages = List(14, 32, 50, 21)
println(ages.size)

// prints 4

Assignment
Follow the Coding Tutorial and print the list size.


Hint
Use ages.size.


STEP 1 OF 3
    Ctrl + Enter to check

    Array Length in Scala

    Keep going with ScalaAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free