The singleton pattern is one of the easiest patterns (at least to understand), but ended up not so easy to implement in imperative languages like Java & C#! Scala has this concept built into the language, without the complications. Here's how it looks:
object A extends B {
}
There you go! That's singleton for you in Scala :). The keyword object does everything for you.
No comments:
Post a Comment