可能重复:
Scala 中下划线的所有用途是什么?
当我遵循特定教程时,我碰巧看到以下两种用法给出了相同的结果。我理解第一个,但我不明白为什么第二个也有效。谁能给我一个解释,同时总结一下_的用法?
def sum (a:Int, b:Int) = a + b
val sumAsFunction1 = sum(_:Int, _:Int)
// I understand this, _ used as placeholder of parameters
val sumAsFunction2 = sum _
// why this usage has the same effect as sumAsFunction1?