You can assign multiple variables at once using tuples:
Tuples may be of mixed type:
Scala tuple combines a fixed number of items together so that they can be passed around as a whole.
Scala tuple combines a fixed number of items together so that they can be passed around as a whole. They are one-indexed. Unlike an array or list, a tuple can hold objects with different types but they are also immutable. Here is an example of a tuple holding an integer, a string, and the console:
val t = (1, "hello", Console)
Which is syntactic sugar (short cut) for the following:
val t = new Tuple3(1, "hello", Console)
As you can see, tuples can be created easily:
The swap
method can be used to swap the elements of a Tuple2:
The parameterless execute method has been deprecated and will be removed in a future version of ScalaTest. Please invoke execute with empty parens instead: execute().
The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest