Tags
#collections #scala #tuples
Question

Given the following definition:

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


To access elements of a tuple t, you can use method [...]to access the first element, [...] to access the second, and so on.

t._1, t._2 and so on

Tags
#collections #scala #tuples
Question

Given the following definition:

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


To access elements of a tuple t, you can use method [...]to access the first element, [...] to access the second, and so on.

?

Tags
#collections #scala #tuples
Question

Given the following definition:

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


To access elements of a tuple t, you can use method [...]to access the first element, [...] to access the second, and so on.

t._1, t._2 and so on
If you want to change selection, open original toplevel document below and click on "Move attachment"

#### Parent (intermediate) annotation

Open it
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.

#### Original toplevel document

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

status measured difficulty not learned 37% [default] 0

No repetitions