From 3dbcf1c2c6092b0287bae150eec2271446f95927 Mon Sep 17 00:00:00 2001 From: Pavel Kazlou Date: Sat, 31 Oct 2015 16:22:59 +0300 Subject: [PATCH] added docs for multi-variable tuple assignment --- scala.html.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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