map

Evaluates a function over each element in the list, returning a list with the same number of elements.

val numbers = List(1,2,3,4,5)
val numbers_times2 = numbers.map((i :Int) => i*2)
println(numbers_times2) // List(2,4,6,8,10)

Note: the (i :Int) => i*2 is called Anonymous Function. Also it can be passed in a function.

def addTwo(i: Int): Int = i + 2

val numbers = List(1,2,3,4,5)
val numbers_add2 = numbers.map(addTwo)
println(numbers_add2) // List(3,4,5,6,7)