title: Add element to an array if it's not there already
body: <p>I have a Ruby class</p>
  
  <pre><code>class MyClass
    attr_writer :item1, :item2
  end
  
  my_array = get_array_of_my_class() #my_array is an array of MyClass
  unique_array_of_item1 = []
  </code></pre>
  
  <p>I want to push <code>MyClass#item1</code> to <code>unique_array_of_item1</code>, but only if <code>unique_array_of_item1</code> doesn't contain that <code>item1</code> yet. There is a simple solution I know: just iterate through <code>my_array</code> and check if <code>unique_array_of_item1</code> already contains the current <code>item1</code> or not.</p>
  
  <p>Is there any more efficient solution?</p>