File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ object Array2 {
2+ def unapplySeq (x : Array [Int ]): Data1 = new Data1
3+
4+ class Data1 {
5+ def isEmpty : Boolean = false
6+ def get : Data2 = new Data2
7+ }
8+
9+ class Data2 {
10+ def apply (i : Int ): Int = 3
11+ def drop (n : Int ): scala.Seq [Int ] = Seq (2 , 5 )
12+ def toSeq : scala.Seq [Int ] = Seq (6 , 7 )
13+ def lengthCompare (len : Int ): Int = 0
14+ }
15+ }
16+
17+ object Test {
18+ def test1 (xs : Array [Int ]): Int = xs match {
19+ case Array2 (x, y) => x + y
20+ }
21+
22+ def test2 (xs : Array [Int ]): Seq [Int ] = xs match {
23+ case Array2 (x, y, xs:_* ) => xs
24+ }
25+
26+ def test3 (xs : Array [Int ]): Seq [Int ] = xs match {
27+ case Array2 (xs:_* ) => xs
28+ }
29+
30+ def main (args : Array [String ]): Unit = {
31+ test1(Array (3 , 5 ))
32+ test2(Array (3 , 5 ))
33+ test3(Array (3 , 5 ))
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments