Can't see the real difference between ::
and +:
method of Scala List.
I used REPL to test and can't see diff from the result.
Anyone can give me how can I use that properly?
Can't see the real difference between ::
and +:
method of Scala List.
I used REPL to test and can't see diff from the result.
Anyone can give me how can I use that properly?
Looking at the code of List,
+:
uses::
(cons) operator for prepending.In general,
+:
is defined inSeqLike
and any collection implementingSeqLike
can use the same.On the other hand
::
is defined inList
and can only be used byList
.