这些 Scala 语句是什么意思?你怎么称呼这种语法? [中缀符号]

What do these Scala statements mean? and what do you call this syntax? [infix notation]

我正在尝试找出一些 Scala 代码。这是一个创建可变映射和排序对象的片段。

import scala.collection.mutable

val score = mutable.Map(start -> 0d) withDefaultValue Double.PositiveInfinity
val priority = Ordering by {n: Node => score(n) + heuristic(n)}

您如何称呼这段代码,您只是在没有逗号或括号的情况下将术语放在表达式之后?我有一种感觉,这是 Scala 的功能方面,但不确定。大括号在这种情况下有不同的含义吗?

What do you call this code where you just put terms after an expression without commas or parenthesis?

这是在使用 'infix notation',参见 http://docs.scala-lang.org/style/method-invocation.html

I have a feeling this is the functional aspect of Scala but not sure.

这是'syntactic sugar',与函数式编程没有直接关系。

Do the curly brackets have a different meaning in this context?

在此上下文中,花括号定义了一个表达式块。 此处提供更详细的讨论: What is the formal difference in Scala between braces and parentheses, and when should they be used?