title: Data Structure in ruby to only store unique elements?
body: <p>I want a Data Structure in Ruby which will only store a string only once and reject it the next time I try to put it in(Something like a 'SET').
  The implementation needs to be the most efficient(Better than a Linear Search in an array for instance).</p>
  
  <p>Also I tried using Hash for the purpose, but multiple strings with same value(these strings I get from slice operation on some existing strings) get into the Hash, seems like a different hash value for them is being computed.</p>
  
  <p>What could be the best and most efficient way out? I would not like to use a ruby gem. I am working on an puzzle solution from an online judge for which I can only submit my own code.</p>
  
  <p>Here is the code snippet I wrote:</p>
  
  <pre><code>for string in @string_store do
    for c in 0...string.length
      index_to_sum=0
      while c+index_to_sum&lt;string.length do
        substring=string[c..(c+index_to_sum)]         
        unless @hash_store[substring]=='X'
          @hash_store[substring]='X'
        end
        index_to_sum+=1
      end
    end
  end   
  </code></pre>