Advertisement
imehesz

Singleton Coffee

Aug 8th, 2014
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Singleton = (->
  2.   instance = null
  3.   someVal = 5
  4.  
  5.   init = ->
  6.     run: ->
  7.       console.log "running ..."  
  8.     getVal: ->
  9.       someVal
  10.     setVal: (newVal) ->
  11.       someVal = newVal
  12.     fromZeroToVal: ->
  13.       i=0
  14.       while i<someVal
  15.         console.log "i => " + i
  16.         i++
  17.       return
  18.   getInstance: ->
  19.     instance = init() if instance is null
  20.     instance
  21. )()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement