title: Scala akka: declare a global variable in receive function
body: <p>I want to declare a global variable when an Actor receive some message, here is my code, it works. Q: Can I achieve that with immutable variable?</p>
  
  <pre><code>case class Start(configs:JobConfig)
  trait Job extends Actor with ActorLogging {
    //use "val" instead
    private var confMap:Map[String,String]=Map()
    def receive = {
      case Start(conf) =&gt; {
        confMap = conf.properties
        init()
      }
        case x =&gt; log.debug("Got: " + x)
    }
  
    final def getProperties():Map[String,String]={
      confMap
    }
  
    def init()
  
  }
  </code></pre>