In the comments to Scala Sink or Swim Josh Sureth calls out non-method-local vars as a cause of problems in Scala code.
That page is the only Google hit for the phrase non-method-local vars
, so what does it mean, and what is the problem?
A method local variable is a local variable declared in the scope of a method.
Consequently a non-method-local variable ought to be a variable with a wider scope, such as class scope.
Can't tell for sure why one would say that they are problematic. Perhaps it is simply due to the fact that they introduce a mutable state in objects.
The problem with non-method-local vars is that they introduce mutable states to a class/object. This is something you should avoid whereever you can, because scala is a functional language as well. (In pure functional languages like Haskell variables are forbidden.) Those variables start producing even more problems when you start working parrallel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With