我有以下功能。它可以很好地打印我要存储的值。我想建立一个 Map[String, String]
def storePlayerEntry(n: Node, moved: Boolean) = {
moved match {
// storing a current player record
// rowkey = playerid
case true => {
//println("current: " + teamId + ":" + n)
println("id: " + n \ "@uID")
for (
s <- Seq("first_name",
"last_name",
"known_name",
"birth_date",
"weight",
"height",
"jersey_num",
"real_position",
"real_position_side",
"join_date",
"country")
) {
val stat = (n \\ "Stat").filter(_.attribute("Type").filter(_.toString() == s).isDefined)
Option(stat.text) match {
case Some(st) if (st == "") => // do nothing
case Some(st) => println(st)
case None => // do nothing
}
}
//val ret = dataApi.upsertMulti("players",
}
case false => {
//println("old: " + teamId + ":" + n)
}
}
}
我避免声明地图然后只是添加方法,因为我确信这里有更多的 scala-ish 要做。
我正在寻找的地图将包含类似 s -> st