Finding an item that matches predicate in Scala
Use filter: scala> val collection = List(1,2,3,4,5) collection: List[Int] = List(1, 2, 3, 4, 5) // take only that values that both are even and greater than 3 scala> collection.filter(x => (x % 2 == 0) && (x > 3)) res1: List[Int] = List(4) // you can return this in order to check that there … Read more