Tuple
  • Tuple2, Tuple3, ..., Tuple22
  • Scala tuple combines a fixed number of items
  • Tuple is immutable
  • Tuple can hold objects with different types but they are also immutable
  • object Demo
    {
      def main(args : Array[String])
      {
        // create tuple
        var a = ("Lin", 39)
        var b = Tuple2("Lin", 39)
    
        // access tuple
        println(a._1+" "+a._2)
    
        // swap
        println(a.swap) // 39, Lin
      }
    }
    		
    Reference
  • Tuple2