Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



#collections #scala #tuples

Given the following definition:

val t = (4,3,2,1)

To access elements of a tuple t, you can use method t._1 to access the first element, t._2 to access the second, and so on. For example, the following expression computes the sum of all elements of t:

val sum = t._1 + t._2 + t._3 + t._4
If you want to change selection, open document below and click on "Move attachment"

Scala Tuples
e1, Tuple2, Tuple3 and so on. There currently is an upper limit of 22 in the Scala if you need more, then you can use a collection, not a tuple. For each TupleN type, where 1 <= N <= 22, Scala defines a number of element-access methods. <span>Given the following definition: val t = (4,3,2,1) To access elements of a tuple t, you can use method t._1 to access the first element, t._2 to access the second, and so on. For example, the following expression computes the sum of all elements of t: val sum = t._1 + t._2 + t._3 + t._4 You can use Tupel to write a method that takes a List[Double] and returns the count, the sum, and the sum of squares returned in a three-element Tuple, a Tuple3[Int, Double, Double]. The


Summary

statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

Details



Discussion

Do you want to join discussion? Click here to log in or create user.