我有以下功能。它適用於打印我想要存儲的值。我想建立一個地圖[字符串,字符串]構建地圖[字符串,字符串]
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)
}
}
}
我避免聲明的地圖,則只需添加方法,因爲我敢肯定有更多的東西斯卡拉十歲上下要在這裏完成。
我要找會含有像S上的地圖 - > ST
真棒...謝謝@chiappone。我不能投票了...我的代表太低了:( – kyleroche
去了這個和特拉維斯的混合。) 'var x =(for(s < - playerKeys; val st =(n如果(st!=「」&& st!=「Unknown」)(「!Stat」)。filter( _.attribute(「Type」).filter(_ .toString()== s).isDefined).text if ))yield(s - > st))toMap' – kyleroche
@kyleroche:請注意,由於您正在搜索節點序列(更不用說創建'NodeSeq' )爲每個鍵。 –