3 ms·
i much prefer x || (x = someDefaultValue) because it doesn't require backtracking. by that i mean, when i read x = x || somedefaultValue, i am thinking x = "ok
by aaronblohowiak 16y ago
i much prefer x || (x = someDefaultValue) because it doesn't require backtracking. by that i mean, when i read x = x || somedefaultValue, i am thinking x = "okay, we are in an assignment) and then i see x || and then i have to adjust and think "oh, well, this is a conditional so now i have to think about that situation."
with x || (x = someDefaultValue), what you read is how it is evaluated. if x is true, the rhs is never evaluated. with the above, the assignment happens either way.