Scala 3, Programming Scala.
val map2a = xs.map: x => val y = x - 1 y * y // val map2a: IndexedSeq[Int] = Vector(1, 0, 1, 4, 9, 16, 25, 36, 49, 64) It’s not especially nice having the argument list on a line by itself. Fortunately, this isn’t required. We can put the x => after the : on the same line: val map1b = xs.map { x =>