Merge pull request #1951 from pikazlou/scala-tuples-usage

additional docs for tuple usage
This commit is contained in:
Geoff Liu 2015-12-18 17:21:48 -05:00
commit 7625a0cbd8

View File

@ -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