ruby-style-guide
ruby-style-guide copied to clipboard
[idea?] Using ternary with array push operator
When using ternary with array push operator, the result may surprise you depending on your knowledge of operator precedence.
array = []
# bad
array << true ? 1 : 0
=> 1
# array = [true]
# good (?)
array << (true ? 1 : 0)
# array = [1]