In Scala, for many (all?) types of collections you can create views.
What exactly is a view and for which purposes are views useful?
One use case is when you need to collect first result of elements transformation:
case class Transform(n: Int) { println("Transform "+n)}
val list = List(1,2,3,4,5)
list.view.map(v => Transform(v)).collectFirst{case Transform(3) => println("found")}
Prints:
Transform 1
Transform 2
Transform 3
found
While:
list.map(v => Transform(v)).collectFirst{case Transform(3) => println("found")}
Prints:
Transform 1
Transform 2
Transform 3
Transform 4
Transform 5
found