为什么Scala不能编译混合了空格和点的函数链?

为什么Scala不能编译混合了空格和点的函数链?,scala,compilation,Scala,Compilation,这包括: paragraphs.map { a => }.filter { b => }.map { c => }.sortBy { d => }.reverse 这也是: paragraphs map { a => } filter { b => } map { c => } sortBy { d => } reverse // <- warning about postfix notation 是运算符优先级吗?如果是

这包括:

paragraphs.map { a =>

}.filter { b =>

}.map { c =>

}.sortBy { d =>

}.reverse
这也是:

paragraphs map { a =>

} filter { b =>

} map { c =>

} sortBy { d =>

} reverse // <- warning about postfix notation

是运算符优先级吗?如果是这样的话,为什么选择一个版本而不是另一个呢?

点优先,所以它得到的是:

(1 to 5) map { a => a } filter ({ b => true }.reverse)
<console>:11: error: missing parameter type
           (1 to 5) map { a => a } filter ({ b => true }.reverse)
                                             ^
但是,请注意,现在不建议使用后缀运算符,即不带点的运算符,如果您尝试使用它们,则会收到警告:

~$ scala -feature
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.

scala> (1 to 5) map { a => a } filter { b => true } reverse
<console>:11: warning: postfix operator reverse should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scala docs for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
       (1 to 5) map { a => a } filter { b => true } reverse

点优先,所以它得到的是:

(1 to 5) map { a => a } filter ({ b => true }.reverse)
<console>:11: error: missing parameter type
           (1 to 5) map { a => a } filter ({ b => true }.reverse)
                                             ^
但是,请注意,现在不建议使用后缀运算符,即不带点的运算符,如果您尝试使用它们,则会收到警告:

~$ scala -feature
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.

scala> (1 to 5) map { a => a } filter { b => true } reverse
<console>:11: warning: postfix operator reverse should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scala docs for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
       (1 to 5) map { a => a } filter { b => true } reverse

请发表你的问题。请发表你的问题。稍微澄清一下:后缀运算符即,没有点应该没有点和参数。编译器想要反转,但是1到5映射{a=>a}过滤器{b=>true}是可以的。编译器想要反向,但是1到5映射{a=>a}过滤器{b=>true}可以。