Lambda use with a map function

Report a typo

We have a list of some Persons:

case class Person(name: String, age: Int, gender: String)

val people: List[Person]

Transform people to a new list of tuples with the name age, using only a lambda function. Save the result to the nameAndAge list.

Sample Input 1:

Person(John,25,Male)
Person(Jane,30,Female)
Person(Bob,20,Male)
Person(Sara,35,Female)

Sample Output 1:

(John,25)
(Jane,30)
(Bob,20)
(Sara,35)
Write a program in Scala 3
val nameAndAge: List[(String, Int)] = people.map { ??? }
___

Create a free account to access the full topic