tags:

views:

109

answers:

1

Possible Duplicate:
What does ||= mean in Ruby?

what is ||= in ruby?

A: 

It's a conditional assignment. If the variable is nil or false it will be replaced with the value on the right hand side; if it already has a value other than nil or false it will keep that value.

Russ Cam
Oops. Counter-example: `x = false; x ||= 42; x`
pst
Oops, I missed out the `false` part. Corrected, thanks :)
Russ Cam