What Scala feature implements factory patterns and persistent (singleton?) objects? -
what scala feature can class become factory? , return persistent objects database connections?
i familiar python, less familiar java , spent few hours scala (tutorials). working counter-intuitive ideas scala classes head; thinking in terms of more intuitive features.
see companion object in scala:
class example(val string:string) {   private var extradata = ""   override def tostring = string+extradata } object example {   def apply(base:string, extras:string) = {     val s = new example(base)     s.extradata = extras     s   }   def apply(base:string) = new example(base) } println(example("hello"," world")) println(example("hello")) there connected class same name.
for persistence objects scala use same stuff java - jpa hibernate openlink
see using jpa scala
Comments
Post a Comment