On 13 Feb 2019, at 12:22, Konrad Hinsen <konrad.hinsen@fastmail.net> wrote:
On 11/02/2019 17:18, Cyril Ferlicot wrote:
A quick question: is it possible to use traits to define class methods?
For example, could the popular singleton pattern consisting of the three class methods #uniqueInstance, #new, and #reset plus the instance variable uniqueInstance be packaged as a trait? Hi,
Yes it is possible.
Thanks for your encouragement!
I ended up trying exactly that example, and it works just fine:
It is amazing how much better this feels now that Traits can define state, too⦠(compared to before where it was just methods). https://github.com/khinsen/SingletonTrait/blob/master/SingletonTrait/Singlet... I would even want to have (and use) a Trait like that in the system by default. Marcus