Skip to content

Instantly share code, notes, and snippets.

@mariozig
Created February 3, 2013 03:17
Show Gist options
  • Select an option

  • Save mariozig/4700419 to your computer and use it in GitHub Desktop.

Select an option

Save mariozig/4700419 to your computer and use it in GitHub Desktop.
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