Scala in java code : $colon

bytecode, scala, syntax

Solution

$colon is a mangling for the symbol :. Since : (and other letters) is an illegal letter in java for method names but allowed in scala, a strategy is needed to encode it into a legal name. Hence, the $colon

Here your code translate to arg :: Nil which adds arg to the empty list, constructing a List with arg as single element.

Problem

I read some java source code which including Scala source code. I found `Nil.$colon$colon(Object arg)` What does keywords `$colon` mean? And what does this line mean?

Original source