Triple colon Scala

I am trying to pick up some scala. After reading the examples, I came across this infallible nugget:

case 3 => l ::: List(3) 

What does a triple colon do?

+48
scala
01 Oct '11 at 15:06
source share
2 answers

Merging two lists - javadoc

+54
01 Oct '11 at 15:09
source share

To add to gkamal's answer , it’s important to understand that methods whose names end in a colon are right-associative. Therefore, the notation l ::: List(3) coincides with the notation List(3).:::(l) . In this case, it does not matter, since both operands are lists, but in general you will need this knowledge to find such methods in scaladocs.

It also helps to find out that scaladocs have a full index of all methods (and classes, etc.) with symbolic names. You can get to it by pressing # in the upper left corner.

+43
Oct 01 '11 at 3:26 a.m.
source share



All Articles