Scala元组

  

object TupleTest {

  def basic(firstName: String, lastName: String, age: Int): (String, String, Int) = (firstName, lastName, age)

  def main(args: Array[String]) {
val member = basic("alex", "cao", 22)
println("Hello, my name is " + member._1 + " " + member._2 + ", and I am " + member._3 + " years old")
}
}

Scala元组可以组合不同类型数据, 目前支持的元素个数最多为22个

上一篇:Oulipo(Hash入门第一题 Hash函数学习)


下一篇:菜鸟笔记:java变量命名及峰驼式命名法