mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-22 21:52:31 +03:00
added docs for multi-variable tuple assignment
This commit is contained in:
parent
e56bc6cbca
commit
3dbcf1c2c6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user