创建元组
scala> val t = (
1,
"hello",
Console)
t: (
Int,
String,
Console.
type) = (1,hello,scala.Console$@47b530e0)
scala> val t = new
Tuple3(
1,
"hello",
Console)
t: (
Int,
String,
Console.
type) = (1,hello,scala.Console$@47b530e0)
获取元组中的数据
scala> t._1+t._2
res13: String =
1hello
遍历元组
scala> t
.productIterator.foreach(i=>println(i))
1
hello
scala
.Console$
@47b530e0
转化成String
scala> t
.toString()
res15: String = (
1,hello,scala
.Console$
@47b530e0)
转载请注明原文地址: https://www.6miu.com/read-28058.html