How do I declare a constructor for an 'object' class type in Scala? I.e., a one time operation for the singleton.
        Posted  
        
            by 
                Zack
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Zack
        
        
        
        Published on 2011-03-04T23:05:48Z
        Indexed on 
            2011/03/04
            23:24 UTC
        
        
        Read the original article
        Hit count: 227
        
scala
I know that objects are treated pretty much like singletons in scala. However, I have been unable to find an elegant way to specify default behavior on initial instantiation. I can accomplish this by just putting code into the body of the object declaration but this seems overly hacky. Using an apply doesn't really work because it can be called multiple times and doesn't really make sense for this use case.
Any ideas on how to do this?
© Stack Overflow or respective owner