Scope
Fields
  • The fields are accessible from inside every method in the object
  • Fields can also be accessible outside the object depending on what access modifiers the field is declared with
  • Object fields can be both mutable and immutable types and can be defined using either var or val
  • Method Parameters
  • Method parameters are only accessible from inside the method
  • The objects passed in may be accessible from the outside, if you have a reference to the object from outside the method, it is an immutable reference to a mutable object
  • Method parameters are always immutable which are defined by val keyword
  • Local Variables
  • Local variables are only accessible from inside the method
  • Local variables can be both mutable and immutable types and can be defined using either var or val