summaryrefslogtreecommitdiffhomepage
path: root/scala.html.markdown
diff options
context:
space:
mode:
authorPavel Kazlou <p.i.kazlou@gmail.com>2015-10-31 16:22:59 +0300
committerPavel Kazlou <p.i.kazlou@gmail.com>2015-10-31 16:22:59 +0300
commit3dbcf1c2c6092b0287bae150eec2271446f95927 (patch)
tree79a16cf0b688ca86ea099a52f821c7b93270fd72 /scala.html.markdown
parente56bc6cbca1058f61f2fb7247888eb52068cb63d (diff)
added docs for multi-variable tuple assignment
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 192e03d7..4ba9a31b 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -321,9 +321,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