I often encounter the following case: I want to set a variable unless it is present. Of course this can be easily done by doing so:
var1 = ""
var1 = "dhiughr" unless var1.present?
If it was nil this could be done with a simple ||= operator, but since an empty string is not nil it won't work. I have tried reading on Ruby's or operator, which theoretically should work:
var1 = "" or "dhiughr"
but it doesn't. I expect the second string (right from the operator) to be chosen when the first isn't present?
What am I doing wrong?
oroperator theoretically should work"?