Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matthandlersux/3057591 to your computer and use it in GitHub Desktop.
Save matthandlersux/3057591 to your computer and use it in GitHub Desktop.
any way to make this cleaner?
abstract class SuperClass {
var initialized = false
def initialize {
initialized = true
}
}
abstract trait SubclassCompanion {
def create:Any
}
object Subclass1 extends SuperClass with SubclassCompanion {
def create {
val obj = new Subclass1()
obj.initialize
obj
}
}
class Subclass1 extends SuperClass {
}
object Subclass2 extends SuperClass with SubclassCompanion {
def create {
val obj = new Subclass2()
obj.initialize
obj
}
}
class Subclass2 extends SuperClass {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment