Created
August 17, 2010 22:21
-
-
Save minikermit/532378 to your computer and use it in GitHub Desktop.
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
A common idiom is to use || to assign a value to a variable only if that variable isn't already set. This can be written as: | |
1. @variable = @variable || "default value" | |
@variable = @variable || "default value" | |
or, more idiomatically, as: | |
1. @variable ||= "default value" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment