Skip to content

Instantly share code, notes, and snippets.

@freakflames29
Created April 14, 2021 06:24
Show Gist options
  • Save freakflames29/7c90d49d1a0bd4870291971a87b67249 to your computer and use it in GitHub Desktop.
Save freakflames29/7c90d49d1a0bd4870291971a87b67249 to your computer and use it in GitHub Desktop.
Ruby equal or operator
x ||= {}
x[:key]="lock"
x[:key]||=50
puts x
# output {:key=>"lock"}
#it is used to assign a value to variable if the variable is not assigned and afer assigning the value we can't change it to new value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment