What is default evaluation strategy in Scala?
Explanation
It turns out that, for expressions in practice, call-by-value is often exponentially more efficient than call-by-name because it avoids this repeated recomputation of argument expressions that call-by-name entails.
The other argument for call-by-value is that it plays much nicer with imperative effects and side effects because you tend to know much better when expressions will be evaluated.
Since Scala is also an imperative side, call-by-value is the standard choice. Except that, sometimes you really want to force call-by-name, and Scala lets you do that also. You do that by adding an arrow in front of the parameter type.
More information: Evaluation Strategies and Termination

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes