diff --git a/examples/src/UpdfateOperation.jetl b/examples/src/UpdfateOperation.jetl new file mode 100644 index 00000000000..f5c05579d8b --- /dev/null +++ b/examples/src/UpdfateOperation.jetl @@ -0,0 +1,14 @@ +class Pair(x : Int, y : Int) { + class object { + 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 p3 = Point.Copy(p) + +// Such copy(...) methods can be automatically generated by the compiler +// whenever there is a primary constructor \ No newline at end of file