Although a triple colon is a right-associative operator, the following result says it's not true, is it?
List(3, 4, 5) ::: List(18, 19, 20) //> List[Int] = List(3, 4, 5, 18, 19, 20)
From my point of view, the result should be List(18, 19, 20, 3, 4, 5)
since it's the same as saying:
List(18, 19, 20).:::(List(3, 4, 5))
Do I understand the definition of being a right-associative wrong?
From the docs:
def :::(prefix: List[A]): List[A]
[use case] Adds the elements of a given list in front of this list.
Example:
List(1, 2) ::: List(3, 4) = List(3, 4).:::(List(1, 2)) = List(1, 2, 3, 4)
prefix - The list elements to prepend.
returns - a list resulting from the concatenation of the given list prefix and this list.
This says it all. As for the right-associative operations, you're right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With