summaryrefslogtreecommitdiffhomepage
path: root/scala.html.markdown
diff options
context:
space:
mode:
authorGeoff Liu <cangming.liu@gmail.com>2015-12-18 17:21:48 -0500
committerGeoff Liu <cangming.liu@gmail.com>2015-12-18 17:21:48 -0500
commit7625a0cbd876eedb2c911961e81b80de7b353bc7 (patch)
tree5fccb6e7eac48383a1b6c4a15f106f4897f7178a /scala.html.markdown
parent96bf58057945a4e394a7f1a3a726863570d30acb (diff)
parent3dbcf1c2c6092b0287bae150eec2271446f95927 (diff)
Merge pull request #1951 from pikazlou/scala-tuples-usage
additional docs for tuple usage
Diffstat (limited to 'scala.html.markdown')
-rw-r--r--scala.html.markdown8
1 files changed, 7 insertions, 1 deletions
diff --git a/scala.html.markdown b/scala.html.markdown
index 56f31f33..a82983a5 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -327,9 +327,15 @@ divideInts(10, 3) // (Int, Int) = (3,1)
val d = divideInts(10, 3) // (Int, Int) = (3,1)
d._1 // Int = 3
-
d._2 // Int = 1
+// Alternatively you can do multiple-variable assignment to tuple, which is more
+// convenient and readable in many cases
+val (div, mod) = divideInts(10, 3)
+
+div // Int = 3
+mod // Int = 1
+
/////////////////////////////////////////////////
// 5. Object Oriented Programming