{ case => ...}被称为case序列(见《Scala编程》中文版之“作为偏函数的case序列”),它可以出现在任何允许函数字面量出现的地方。而*.map { case => ...}省略了*.map()里的(),见下面例子
def main(args: Array[String]): Unit = {
def call(method : Int => Int): Unit = {
method(1)
}
call x => x+1 //error
call(x => x+1) //ok
call({x => x+1}) //ok
call{x => x+1} //ok
}
原因是,scala允许代码块作为参数时,省略()。见syntax - What is the formal difference in Scala between braces and parentheses, and when should they be used? - Stack Overflow