#collections #scala #tuples
Here is an example of a tuple holding an integer, a string, and the console:
val t = (1, "hello", Console)
Which is syntactic sugar (short cut) for the following:
val t = new Tuple3(1, "hello", Console)
If you want to change selection, open document below and click on "Move attachment"
Scala Tuplesements
Previous Page
Next Page
Scala tuple combines a fixed number of items together so that they can be passed around as a whole. Unlike an array or list, a tuple can hold objects with different types but they are also immutable. <span>Here is an example of a tuple holding an integer, a string, and the console:
val t = (1, "hello", Console)
Which is syntactic sugar (short cut) for the following:
val t = new Tuple3(1, "hello", Console)
The actual type of a tuple depends upon the number and of elements it contains and the types of those elements. Thus, the type of (99, "Luftballons") is Tuple2[Int, String]. Th Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details