providence
providence

Reputation: 29463

Triple colon Scala

I'm trying to pick up some scala. Reading through examples I came across this impossible-to-google nugget:

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

What does the triple colon accomplish?

Upvotes: 61

Views: 14431

Answers (2)

Aaron Novstrup
Aaron Novstrup

Reputation: 21017

To add to gkamal's answer, it's important to understand that methods whose names end in a colon are right-associative. So writing l ::: List(3) is the same as writing List(3).:::(l). In this case it doesn't matter since both operands are lists, but in general you'll need this knowledge to find such methods in the scaladocs.

It also helps to know that the scaladocs have a comprehensive index of all methods (and classes, etc) with symbolic names. You can reach it by clicking on the # in the upper-left corner.

Upvotes: 52

gkamal
gkamal

Reputation: 21000

Concatenates two lists - javadoc

Upvotes: 66

Related Questions