File: t6963c.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (25 lines) | stat: -rw-r--r-- 602 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
object Test {
  def f1(x: Any) = x.isInstanceOf[Seq[_]]
  def f2(x: Any) = x match {
    case _: Seq[_]  => true
    case _          => false
  }

  def f3(x: Any) = x match {
    case _: Array[_]  => true
    case _            => false
  }

  def f4(x: Any) = x.isInstanceOf[Traversable[_]]

  def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match {
    case (Some(_: Seq[_]), Nil, _)        => 1
    case (None, List(_: List[_], _), _)   => 2
    case _                                => 3
  }

  def f5: Unit = {
    import scala.collection.mutable._
    List(1,2,3,4,5).scanRight(0)(_+_)
  }
}