I am looking for a way to initialize a companion object with arguments. I tried this, it has the risk for re-instantiation. 
private[mypackage] class A(in:Int) {
  def method = {}
}
object A {
  var singleton: Option[A] = None
  def getInstance(): A = {
    if(singleton.isDefined)
      singleton.get
    else {
        throw InitializationException("Object not configured")
      }
  }
  def getInstance(in:Int): A = {
    singleton = Some(new A(in))
    singleton.get
  }
}
Is there a better way?
 
     
     
    