Start learning free

LESSON 236 OF 348 · HASH TABLE

Maps in Scala in Scala

Lesson

A Scala Map is useful when you need fast lookup by key.

val scores = Map("Ana" -> 90, "Ben" -> 75)
println(scores.contains("Ana"))

Assignment
Follow the Coding Tutorial and practice using maps.


Hint
Use key -> value pairs when creating a map.


STEP 1 OF 5
    Ctrl + Enter to check

    Hash Map 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