By default:
val
, not var
, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution.recursion
and comprehensions
s, not loops.val
whenever possible.There are good reasons to choose non-functional style:
var
can be used for local state (for example, inside an actor).mutable
gives better performance in certain situations.