Matches reorganized

This commit is contained in:
Andrey Breslav
2010-11-25 21:52:40 +03:00
parent ff3f7d8226
commit 4690ea2bc7
5 changed files with 32 additions and 8 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
class Pair(x : Int, y : Int) {
class object {
fun copy(from : Pair, x : int = from.x, y : Int = from.y) = new Pair(x, y)
fun copy(from : Pair, x : Int = from.x, y : Int = from.y) = new Pair(x, y)
}
}
// One can say:
val p = new Point(1, 2)
val p1 = Point.Copy(p, x : 2)
val p2 = Point.Copy(p1, y : -1)
val p1 = Point.Copy(p, x = 2)
val p2 = Point.Copy(p1, y = -1)
val p3 = Point.Copy(p)
// Such copy(...) methods can be automatically generated by the compiler