Did some examples… on Scala’s REPL.
I totally forgot to type Array when instantiating an Array object (trying to test ++ operator).
Anyway, now I’m wondering what datatype is this?
val one = (1,2,3)
Or what data structure or container is the code above? What is this call? Why is it useful? I don’t believe the REPL gave any useful information on what the above code is.
Thank you for your time.
This is special syntax for constructing a
Tuple3object. It’s equivalent toTuples are defined up to
Tuple22. One important use case for tuples is returning multiple values from a function. Tuples can also be unpacked with special syntax: