You can compare numeric types with relational methods greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=), which yield a Boolean result. In addition, you can use the unary '!' operator(the unary_! method)
The logical-and and logical-or operations are short-circuited as in Java: expressions built from these operators are only evaluated as far as needed to determine the result.
In other words, the right-hand side of logical-and and logical-or expressions won't be evaluated if the left-hand side determines the result.
In the first expression, pepper and salt are invoked, but in the second, only salt is invoked. Given salt returns false, there's no need to call pepper.
Scala methods have a facility for delaying the evaluation of their arguments, or even declining to evaluate them at all.
The facility is call by-name parameters.
댓글 없음:
댓글 쓰기