【发布时间】:2016-07-07 03:48:00
【问题描述】:
在 Scala 中 repl
scala> List(1) :: 2
<console>:8: error: value :: is not a member of Int
List(1) :: 2
但是
scala> 2 :: List(1);
res4: List[Int] = List(2, 1)
这是反直觉的,因为如果从左到右读取中缀运算符,则上面的行可以转换为
List(1) :: 2
List(1).::(2)
和
2 :: List(1)
2.::(List(1))
我想Int 没有方法:: 而List 有。我假设有什么问题吗?
【问题讨论】:
标签: scala functional-programming operators