Last active
January 4, 2016 20:49
-
-
Save marcelmorgan/8676609 to your computer and use it in GitHub Desktop.
Array of CONSTANTS
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
# Lets say we need to have a list of all our states | |
# we could do it like this | |
ON = 'on' | |
OFF = 'off' | |
CLOSED = 'closed' | |
STATES = [ON, OFF, CLOSED] | |
# but adding a new state means adding it in 2 places | |
# versus | |
STATES = [ | |
ON = 'on', | |
OFF = 'off', | |
CLOSED = 'closed', | |
] | |
# here we only need to add it once |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment