[フレーム]
Last Updated: February 25, 2016
·
1.383K
· robinduckett

Make a singleton in CoffeeScript

class SingletonClass
 constructor: () ->
 @list = []
 getList: ->
 @list


INSTANCE = undefined

Singleton =
 instance: ->
 if INSTANCE is undefined
 INSTANCE = new SingletonClass()

 INSTANCE

AltStyle によって変換されたページ (->オリジナル) /