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 -

see using jpa scala


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -