I’m looking for a collect method in scala 2.7 but I can’t seem to find an applicable call. Is there something equivalent to collect that I can use in scala?
To be clear I’m looking to filter elements from a list and map those filtered to a new type.
You can use
flatMap(the full method signature in 2.7 isdef flatMap[B](f : (A) => Iterable[B]) : List[B]). It is declared on bothIterableandIterator(with slightly different signatures):In the above example I’m taking advantage of an explicit conversion
option2iterableinPredef. It’s declared in 2.8 onTraversableLike: