blob: a992e5f2a554ede4ef6b5dfe5e4012802e1c3f0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
object Test extends Application {
class QSRichIterable[A](self:Iterable[A]) {
def filterMap[R](f: PartialFunction[A,R]) =
self filter (f.isDefinedAt) map f
}
object Un {
def unapply(i:int): Option[int] = Some(i)
}
val richIter = new QSRichIterable(List(0, 1, 2, 3, 4))
assert((richIter filterMap {case Un(3) => 7}) == List(7))
}
|