Some bang version of Array
methods are like compact!
, reject!
, flatten!
, uniq!
return nil
if no
The bang (!
) methods do modify the current object in place, but they do return nil
if there are no affected elements per the documentation. This is useful if, for whatever reason, you need to do something if you did modify the array in question.
if array.flatten!
puts "Oh yeah... flattened that array!"
end