equal
deleted
inserted
replaced
|
1 |
|
2 case class Twice(i: Int) { |
|
3 def apply(x: Int, y: Int): Int = x * y |
|
4 //def unapply(z: Int): Option[Int] = if (z % 2 == 0) Some(z/2) else None |
|
5 } |
|
6 |
|
7 Twice(21) match { |
|
8 case Twice(n) => println(n) |
|
9 } |
|
10 |
|
11 Twice(21, 3) match { |
|
12 case Twice(n) => println(n) |
|
13 } |
|
14 |
1 |
15 |
2 package Main |
16 package Main |
3 |
17 |
4 object ComprehensionsTest extends App { |
18 object ComprehensionsTest extends App { |
5 def even(from: Int, to: Int): List[Int] = |
19 def even(from: Int, to: Int): List[Int] = |