2

I'm absolutely new to Xtend, but browsing the documentation and searching the Web unfortunately didn't bring up a clear answer.

I really do like the way one can define a singleton object in Scala.

Is there a counterpart to this in Xtend or do I have to fall back to implementing the singleton pattern myself?

gjveltink
  • 31
  • 5
  • If you're comfortable with a bit of Java, just write a single-constant enum there. – Ionuț G. Stan Jan 27 '15 at 19:52
  • 1
    No, there's none, as Singletons are not so popular these days (testability). We could easily have an annotation @Singleton that does the plumbing. If you feel that's useful please file a bugzilla. – Sven Efftinge Jan 28 '15 at 18:29
  • @SvenEfftinge Thanks for this clear reply directly from the source! I'm aware that Singletons have lost their charm and I do know about the problems that can arise, nevertheless once in a while you'll need one and I find the Scala solution to this absolutely charming and actually better than the Singleton Pattern. I will ponder a request for an annotation though. – gjveltink Jan 28 '15 at 21:45

1 Answers1

1

From the comments: @SvenEfftinge No, there's none, as Singletons are not so popular these days (testability). We could easily have an annotation @Singleton that does the plumbing. If you feel that's useful please file a bugzilla.

gjveltink
  • 31
  • 5