summaryrefslogtreecommitdiff
path: root/test/files/run/t1220.scala
blob: 75e0ea07e8b2c185c2d7229f87bc9429fc31d4e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
object Test extends App {

  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))
}