I have a protected method in my application contoller
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
I was wondering what ||=
means?
I've been trying to search and find out, but to no avail.
Some common synonyms of duplicate are copy, facsimile, replica, and reproduction. While all these words mean "a thing made to closely resemble another," duplicate implies a double or counterpart exactly corresponding to another thing.
Septuplicate Definition & Meaning - Merriam-Webster.
The verb duplicate is pronounced differently, with a long a sound, and it means to make a copy of or to multiply times two. The Latin root, duplicatus, means "to double." “Could you please duplicate this letter for me?”
Duplicate may be used as a noun, verb or adjective. Related words are duplicates, duplicated, duplicating, duplication. The word duplicate is derived from the Latin word duplicare, which means to double. Replicate means to reproduce something, to construct a copy of something, to make a facsimile.
Basically, a ||= b
means assign b to a if a is null or undefined or false (i.e. false-ish value in ruby)
, it is similar to a = b unless a
, except it will always evaluate to the final value of a
(whereas a = b unless a
would result in nil
if a
was true-ish).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With