Skip to content

Scala Map

Basics

From chapter 56 of functional-programming-simplified:

The type signature for the map method on the Scala List class looks like this:

map[B](f: A => B): List[B]

Usage:

val x = List("hi", "world").map(s => s.length)
// x: List[Int] = List(2, 5)