blob: f7994a0935ddd2189f7753fb79d5b9cc0aabd3a1 (
plain) (
blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
object Patterns {/*
('1', "1") match {
case (digit, str) => true
case _ => false
}
object Breakdown {
def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
}
object Test2 {
42 match {
case Breakdown("") => // needed to trigger bug
case Breakdown("foo") => // needed to trigger bug
case Breakdown("", who) => println ("hello " + who)
}
}
val names = List("a", "b", "c")
object SeqExtractors {
val y = names match {
case List(x, z) => x
case List(x) => x
case List() => ""
}
val yy: String = y
}
val xs = List('2' -> "ABC", '3' -> "DEF")
xs filter {
case (digit, str) => true
case _ => false
}
(xs: Any) match {
case x: Int @unchecked => true
case xs: List[Int @ unchecked] => true
case _ => false
}
def sum(xs: List[Int]): Int = xs match {
case Nil => 0
case x :: xs1 => x + sum(xs1)
}
def len[T](xs: List[T]): Int = xs match {
case _ :: xs1 => 1 + len(xs1)
case Nil => 0
}*/
final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
case _ :: xs1 =>
ys match {
case _ :: ys1 => sameLength(xs1, ys1)
case _ => false
}
case _ => ys.isEmpty
}
}
|