I’m new to scala, and what I’m learning is tuple.
I can define a tuple as following, and get the items:
val tuple = ("Mike", 40, "New York")
println("Name: " + tuple._1)
println("Age: " + tuple._2)
println("City: " + tuple._3)
My question is:
- How to get the length of a tuple?
- Is tuple mutable? Can I modify its items?
- Is there any other useful operation we can do on a tuple?
Thanks in advance!
1]
tuple.productArity2] No.
3] Some interesting operations you can perform on tuples: (a short REPL session)
See scaladocs of Tuple2, Tuple3 etc for more.