mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Merge pull request #1951 from pikazlou/scala-tuples-usage
additional docs for tuple usage
This commit is contained in:
commit
7625a0cbd8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user