Answer the question
In order to leave comments, you need to log in
What does the ||= operator mean in ruby?
Unfortunately, I couldn't find the answer on ruby-doc.org and on the first pages of google.
Found in this context:
def permitted_params
@permitted_params ||= declared(params,
include_missing: false)
end
Answer the question
In order to leave comments, you need to log in
In this case, ||= means that if the variable @permitted_params is not assigned a value, i.e. it is equal to nil or false, then you need to assign declared(params, include_missing: false) to it, therefore @permitted_params = declared(params, include_missing: false).
Otherwise, if it has a value, nothing needs to be done.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question