Re:Yoda Conditions
by mirekrusin on Friday February 17, 2017 @10:58AM
(#13669105)
Exactly, and use 'if ((a = b)) ...' in those rare cases when it's appropriate.
[ Parent
| on HN ]
Even then I would prefer an explicit comparison:
if ((a = b) != NULL) ...
I think Rust has a happy medium, where assignment evaluates to (), not the variable (important as this means you don't have an implicit borrow), but the idiom expressed here is usually replaced by: if let Some(thing) = fn_that_returns_option_thing() ...