Sacla 转 Array[(String,String)] 为 Map[String,String]

Sacla 转 Array[(String,String)] 为 Map[String,String]
比如将 Array((“name”,”alex”),(“age”,”18”)) 转为 Map(name -> alex, age -> 18)

转换 Array[(String,String)] 为 Map[String,String]

1
2
3
4
5
scala> val arryTuple2 = Array(("name","alex"),("age","18"))
arryTuple2: Array[(String, String)] = Array((name,alex), (age,18))

scala> val map = Map(arryTuple2:_*)
map: scala.collection.immutable.Map[String,String] = Map(name -> alex, age -> 18)