Start learning free

LESSON 101 OF 348 · DICTIONARIES

Maps in Scala in Scala

Lesson

A Scala Map stores key-value pairs. Each key maps to one value.

val ages = Map("Ana" -> 12, "Ben" -> 15)
println(ages("Ana"))

Assignment
Follow the Coding Tutorial and practice using maps.


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


STEP 1 OF 1
    Ctrl + Enter to check

    Dictionaries 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