summaryrefslogtreecommitdiff
path: root/test/files/run/tuples.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/tuples.scala')
-rw-r--r--test/files/run/tuples.scala28
1 files changed, 25 insertions, 3 deletions
diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala
index 3d0dcf7ac0..857b166917 100644
--- a/test/files/run/tuples.scala
+++ b/test/files/run/tuples.scala
@@ -1,8 +1,30 @@
+import Function._
+
object Test extends Application {
- var xyz: Triple(int, String, boolean) = _
- xyz = Triple(1, "abc", true)
+ var xyz: (int, String, boolean) = _
+ xyz = (1, "abc", true)
Console.println(xyz)
xyz match {
- case Triple(1, "abc", true) => Console.println("OK")
+ case (1, "abc", true) => Console.println("OK")
}
+ def func(x : int, y : String, z : double) : unit = {
+ Console.println("x = " + x + "; y = " + y + "; z = " + z);
+ }
+
+ def params = (2, "xxx", 3.14159) // (*****)
+
+ tupled(&func)(params) // call the function with all the params at once
+ func(2, "xxx", 3.14159) // the same call
+ (&func).apply(2, "xxx", 3.14159) // the same call
+
+ // Composing a tuple
+ def t = (1, "Hello", false)
+
+ // Decomposing a tuple
+ val (i, s, b) = t
+
+ // all the assertions are passed
+ assert(i == 1)
+ assert(s == "Hello")
+ assert(b == false)
}