Be Careful with Ruby’s Array Uniq! Method

Got slightly caught up today whilst using the uniq! method on a Ruby array. I expected it to exhibit the same behaviour as Array#uniq, just in place (uniq goes through an array and returns an array with no duplicate elements). So, by that logic, `[“1”].uniq!` would return `[“1”]`. However, that’s not the case. `[“1”].uniq!` actually returns `nil`. Odd, I thought, until I read this:

array.uniq! – Removes duplicate elements from self. Returns nil if no changes are made (that is, no duplicates are found).

Chock up another error to not reading the manual and using the correct method.