I notice that the List class defines a :: method that adds an item to the top of the list
def ::(x: A): List[A]
Example:
1 :: List(2, 3) = List(2, 3).::(1) = List(1, 2, 3)
However, I am confused by how the scala compiler recognizes such a conversion? Because as far as I know
1 :: List(2,3)
should raise error: :: is not a member of Int
Am I missing something about scala statement definition?
source share