Possible Duplicate:
What does ||= (or equals) mean in Ruby?
What does ||= mean?
I have just started learning RubyMotion and in a lot of examples I see the ||= syntax. What does this mean?
Here is an example:
def window
@window ||= begin
w = UIWindow.alloc.initWithFrame UIScreen.mainScreen.bounds
w.rootViewController = @navigationController
w
end
It is difficult to search symbols, google ignored the symbols in my query.
It is an assignment operator which means: or assign this value to a variable.
So if you did something like
x ||= ythis meansx || x = yso if x is nil or false set x to be the value of y.