What is a non-method-local var in Scala?

In comments on the Scala Shell or Swim, Josh Suret calls non-method-local vars as the cause of the problems in the Scala code.

This page is Google’s only hit for the phrase non-method-local vars, so what does it mean and what is the problem?

+5
source share
2 answers

A local method variable is a local variable declared in the method scope.

Therefore, the non-method-local variable must be a variable with a wider scope, such as the scope of the class.

I can’t say exactly why it can be said that they are problematic. Perhaps this is simply because they inject mutable state into objects.

+7
source

-- , /. , , , scala . ( , Haskell, .) parrallel.

+3

All Articles