Created
February 3, 2013 03:17
-
-
Save mariozig/4700419 to your computer and use it in GitHub Desktop.
a double pipe equals example used in: http://ruby.zigzo.com/2013/02/01/wat-double-pipes-equals-in-ruby/
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
x = method_that_returned_nil() #=> nil | |
x ||= "default" #=> "default" : value of x is nil, so it will be replaced with "default" | |
x ||= "other" #=> "default" : value of x is "default" so it will stay "default" and NOT be set to "other" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment