Created
August 21, 2012 09:30
-
-
Save pedro-vasconcelos/3413916 to your computer and use it in GitHub Desktop.
Test if a variable exists
This file contains 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
winners[buyer] ||= [] is a shortcut to: | |
winners[buyer] = winners[buyer] || [] is a shortcut to: | |
Set winners[buyer] equal to winners[buyer] or, if winners[buyer] is nil, set it to []. | |
You’re just making sure a variable is set before using it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment