From 96040138f575387ca08eed45c64ff95cc3b5f883 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 25 Nov 2010 17:04:00 +0300 Subject: [PATCH] Default parameters, function type examples fixed, tuples with named entries --- examples/src/UpdfateOperation.jetl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/src/UpdfateOperation.jetl 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