What does the cons expression, e.g. 1::twoThree, gets translated to (in terms of method calls)?
What rule is used?
Answer
twoThree.::(1)
if a method's name used in operator notation ends with colon, it is called on the right operand
Tags
#odersky-programming-in-scala-1ed #scala
Question
What does the cons expression, e.g. 1::twoThree, gets translated to (in terms of method calls)?
What rule is used?
Answer
?
Tags
#odersky-programming-in-scala-1ed #scala
Question
What does the cons expression, e.g. 1::twoThree, gets translated to (in terms of method calls)?
What rule is used?
Answer
twoThree.::(1)
if a method's name used in operator notation ends with colon, it is called on the right operand
If you want to change selection, open document below and click on "Move attachment"
Next Steps in Scala s with the associativity of the :: method, but it is actually a
simple rule to remember: If a method is used in operator notation, such as
a * b, the method is invoked on the left
operand, as in a.*(b)—unless the method name ends in a colon. <span>If
the method name ends in a colon, the method is invoked on the
right operand. Therefore, in 1 :: twoThree, the :: method is
invoked on twoThree, passing in 1, like this: twoThree.::(1).
Operator associativity will be described in more detail in
Section 5.8.
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.