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.



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.

Answer
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.

Answer
?

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.

Answer
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

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

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