|
Answer» According to their declarations, Scala VARIABLES are CATEGORIZED into three SCOPES as given below: - Fields: Variables of this type can be accessed from any method within a Web OBJECT, or from outside the object, depending on access modifiers used. Depending on the var and val keywords, they can be mutable or immutable.
- Method Parameters: When a method is invoked, these variables are used to pass values to the method. All method parameters use the val keyword and are strictly immutable. Normally, these are accessed within a method, but a Reference allows ACCESSING them outside the method.
- Local Variables: These are the variables (mutable or immutable) declared inside a method and accessible only within that method. By returning them from the method, they can be accessed outside of the method.
|