What's the fastest/one-liner way to remove duplicates in an array of objects, based on a specific key:value, or a result returned from a method?
For instance, I have 20 XML Element nodes that are all the same name, but they have different "text" values, some of which are duplicates. I would like to remove the duplicates by saying "if element.text == previous_element.text, remove it". How do I do that in Ruby in the shortest amount of code?
I've seen how to do it for simple string/integer values, but not for objects.