Could some one explain to me the meaning of the following Ruby code? (I saw this code snippet in one guy's project):
car ||= (method_1 || method_2 || method_3 || method_4)
What is the difference between the above code and the following code?
car = method_1 || method_2 || method_3 || method_4
----------update--------------
Ok, I got the meaning of ||=
operator after read @Dave's explanation, my next question is if both method_2
, method_3
and method_4
return a value, which one's value will be assigned to car
? (I suppose car
is nil initially)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…