Start learning free

LESSON 125 OF 677 · DICTIONARIES

Maps 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