Created
July 13, 2011 09:02
-
-
Save clyfe/1079954 to your computer and use it in GitHub Desktop.
Behavior with state attached VS State with behavior attached
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Behavior with state attached | |
func = do -> | |
variable = 0 # state | |
-> console.log variable++ # behavior | |
func() # 0 | |
func() # 1 | |
# State with behavior attached | |
state = | |
variable: 0 # state | |
func: -> console.log @variable++ # behavior | |
state.func() # 0 | |
state.func() # 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment