I have List[Int] in Scala. The List is List(1,2,3,4,5,6,7,8,9,10). I want to filter the list so that it only has even numbers. And I w
List[Int]
List(1,2,3,4,5,6,7,8,9,10)
filter
I tend to like the filter approach.
val list1 = List(1,2,3,4,5,6,7,8,9,10) list1.filter(x => x%2 == 0).map(_*2)