我想将以下healthText.text = "Health: " + currentTarget.health;
转换为groupByKey
。
reduceByKey
如何通过像block.groupByKey(_.key)
.reduceGroups((left, right) =>
left.copy(
contributingReferences = left.contributingReferences ++ right.contributingReferences,
linkTypes = left.linkTypes ++ right.linkTypes,
contexts = left.contexts ++ right.contexts
)
)
.map(group =>
group._2.copy(
contributingReferences = ArrayUtil.dedup(group._2.contributingReferences, _.key)
)
)
那样的scala糖语法来实现这一目标?
这是我找到的一个例子
(_+_)