What is default evaluation strategy in Scala?
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

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Scala
Зареєструйся Зараз
або Підпишись на майбутні тести