title: Expression of type KafkaProducer[String,String] doesn't conform to expected type Null
body: <p>I want to be able to initialize the variable <code>producer</code> from the function <code>setProducer</code>.</p>
  
  <pre><code>object MyObj { 
    var producer = null                                                                                                                  
  
    def setProducer(p: KafkaProducer[String,String]): Unit = {           
      producer = p                                                       
    }   
  
    //...
  }
  </code></pre>
  
  <p>However it says that <code>Expression of type KafkaProducer[String,String] doesn't conform to expected type Null</code>.</p>
  
  <p>So, how can I initialize <code>producer</code>?</p>