【发布时间】:2014-10-01 14:40:39
【问题描述】:
鉴于 Scala 中的这段代码:
val mapMerge : (Map[VertexId, Factor], Map[VertexId, Factor]) => Map[VertexId, Factor] = (d1, d2) => d1 ++ d2
可以简写为:
val mapMerge : (Map[VertexId, Factor], Map[VertexId, Factor]) => Map[VertexId, Factor] = _ ++ _
实际上代码所做的是重命名 Map[VertexId, Factor] 的运算符 ++,因此:有没有办法将该运算符分配给变量?就像在这个虚构的例子中一样:
val mapMerge : (Map[VertexId, Factor], Map[VertexId, Factor]) => Map[VertexId, Factor] = Map.++
而且可能通过类型推断就足够了
val mapMerge = Map[VertexId,Factor].++
谢谢
【问题讨论】:
-
你的问题是什么?