8 ms·
These operators such as ++ (concatenation) etc are uniformly available in all collections. It has inherited these operators from base sequence classes/traits sp
by zohebv 15y ago
These operators such as ++ (concatenation) etc are uniformly available in all collections. It has inherited these operators from base sequence classes/traits specifically TraversableLike.
http://www.scala-lang.org/api/rc/scala/collection/TraversableLike.html http://www.scala-lang.org/api/rc/scala/collection/Traversabl...
If you write a fancy skiplist and add a TraversableLike trait you will get these operators and the associated methods for free!
Check the source code for NodeSeq.
https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_9_1_RC4/src//library/scala/xml/NodeSeq.scala#L1 https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_9_...
It does not implement any of these operators.
It just inherits some features
extends immutable.Seq[Node] with SeqLike[Node, NodeSeq] with Equality
provides an equality operator and a builder and gets all the other collection operators for free. These operators have the same semantics and implementation across all collection classes unless you specifically override them.