0
A
回答
5
查看List的代码,+:
使用::
(cons)运算符进行预先计算。
override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[List[A], B, That]): That = bf match {
case _: List.GenericCanBuildFrom[_] => (elem :: this).asInstanceOf[That]
case _ => super.+:(elem)(bf)
}
一般而言,+:
在SeqLike
定义和实施SeqLike
任何集合可以使用相同的。
另一方面::
在List
中定义,只能使用List
。
相关问题
- 1. 功能VS Scala的方法
- 2. Scala的阵列VS载体
- 3. 接口方法agruments数组vs vs util列表
- 4. 块vs代表或块vs方法
- 5. Scala类方法
- 6. Scala - TrieMap vs Vector
- 7. Scala StandardTokenParsers vs JavaTokenParsers
- 8. Scala vals vs vars
- 9. Scala XML:Descendant vs Child
- 10. Scala classOf vs getClass
- 11. Scala列表分区方法的尾递归实现
- 12. 在Scala中定义列表的不同方法
- 13. Scala列表的解压缩方法错误
- 14. 自动代表团在Scala的方法
- 15. scala使用针对表的方法
- 16. 无法在Scala中迭代Java列表
- 17. 方法列表
- 18. Scala不可变映射vs元组列表
- 19. LINQ vs Lambda vs匿名方法vs代表
- 20. Scala - 方法调用语法
- 21. java.util.Iterator到Scala列表?
- 22. Scala注释列表?
- 23. 列表处理Scala
- 24. ArrayBuffer vs ArrayBuilder in scala
- 25. println vs scala的System.out.println
- 26. 将Java方法转换为Scala方法
- 27. 最快的方法合并的两个:字典vs列表
- 28. C#列表泛型扩展方法vs非泛型
- 29. 访问当前文件中的方法列表(VS AddIn)
- 30. 列表vs内置排序()函数的Python排序()方法
::没有为Seq定义,只为列表 – harshtuna
谢谢。改性。 – ttt
另请参阅http://stackoverflow.com/questions/30959597/why-can-i-use-operator-with-seq-in-pattern-matching-but-not-elsewhere – AmigoNico