I have one array and I want to remove ALL instances of a duplicate value inside of that array.
arr = [1, 1, 2, 3, 4, 4, 5]
I want the expected output:
=> [2, 3, 5]
What would be the best way to do this?
p arr.group_by(&:itself).reject{|k,v|v.count>1}.keys
Output
[2, 3, 5]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With