Understanding infix method call and cons operator(::) in Scala

后端 未结 2 2050
予麋鹿
予麋鹿 2021-01-31 10:30

I\'m quite new to Scala programming language, and was trying something out stucked in my mind while I was following the lecture notes at here.

I think I couldn\'t really

2条回答
  •  轮回少年
    2021-01-31 11:10

    It's about precedence not execution order. + has higher precedence than ::, so a + b :: c parses as (a + b) :: c. However infix method calls with regular names have lower precedence, so a foo b c parses as a foo (b c).

    See this question for a list of operators ordered by their precedence in scala.

提交回复
热议问题