Do not warn for assignment in conditionals inside ()
Ruby warns against this code, which is very helpful.
% ruby -we 'if a=1; p a; end' -e:1: warning: found = in conditional, should be == 1
So there's a commonly known practice. In order to express that we're intentionally assigning (not missing one more = sign), we usually add parens around the assignment.
But in fact, Ruby still warns...
% ruby -we 'if (a=1); p a; end' -e:1: warning: found = in conditional, should be == 1
Can this behavior changed not to warn when parenthesized?
Updated by nobu (Nobuyoshi Nakada) about 4 years ago
- Status changed from Open to Closed