Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Tags
#odersky-programming-in-scala-1ed #scala
Question
How does scala decide on precedence when methods are used in operator notation, like 2 + 2 * 7 ? What is Scala's default rule here?
Answer
Scala decides precedence based on the first character of the methods used in operator notation (this rule has exceptions). If the method name starts with a *, for example, it will have a higher precedence than a method that starts with a +.

Tags
#odersky-programming-in-scala-1ed #scala
Question
How does scala decide on precedence when methods are used in operator notation, like 2 + 2 * 7 ? What is Scala's default rule here?
Answer
?

Tags
#odersky-programming-in-scala-1ed #scala
Question
How does scala decide on precedence when methods are used in operator notation, like 2 + 2 * 7 ? What is Scala's default rule here?
Answer
Scala decides precedence based on the first character of the methods used in operator notation (this rule has exceptions). If the method name starts with a *, for example, it will have a higher precedence than a method that starts with a +.
If you want to change selection, open document below and click on "Move attachment"

Basic Types and Operations
he expression above to be 28, you could write the expression like this: (2 + 2) * 7 Given that Scala doesn't have operators, per se, just a way to use methods in operator notation, you may be wondering how operator precedence works. <span>Scala decides precedence based on the first character of the methods used in operator notation (there's one exception to this rule, which will be discussed below). If the method name starts with a *, for example, it will have a higher precedence than a method that starts with a +. Thus 2 + 2 * 7 will be evaluated as 2 + (2 * 7), and a +++ b *** c (in which a, b, and c are variables, and +++ and *** are methods) will be evaluated a +++ (b *** c), because the *** method has a higher precedence than the +++ method. Table 5.3 here shows the precedence given to the first character of a method in decreasing order of precedence, with characters on the same line having the same precedence. The high

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised 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.