summaryrefslogtreecommitdiff
path: root/test/files/run/tuples.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-02-14 13:37:19 +0000
committerMartin Odersky <odersky@gmail.com>2007-02-14 13:37:19 +0000
commit979180ca5f30752d94d64b083b6dbca57dab0c4b (patch)
tree5566e84f9803ef46fd9a24fb1e451babec53190c /test/files/run/tuples.scala
parente5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb (diff)
downloadscala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.gz
scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.bz2
scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.zip
more changes to make tuples (...)
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)
}