title: How to store the result of my algorithm?
body: <p>I have an algorithm that searches through all of my sites users, finding those which share a common property with the user using the algorithm (by going to a certain page). It can find multiple users, each can have multiple shared properties. The algorithm works fine, in terms of finding the matches, but I'm having trouble working out how to store the data so that later I'll be able to use each unit of information. I need to be able to access both the found users, and each of the respective shared properties, so I can't just build a string. This is an example of the output, being run from the perspective of user 1:</p>
  
  <p>user 4<br>
  sharedproperty3<br>
  sharedproperty6</p>
  
  <p>user 6<br>
  sharedproperty6<br>
  sharedproperty10<br>
  shareproperty11</p>
  
  <p>What do I need to do to be able to store this data, and have access to any bit of it for further manipulation? I was thinking of a hash of a hash, but I can't really wrap my head around it. I'm pretty new to programming, and Ruby in particular. Thanks for reading!</p>
  
  <p>EDIT - Here's the code. I'm fully expecting this to be the most incorrect way to do this, but it's my first try so be gentle :)
  So if I'm understanding you guys correctly, instead of adding the interests to a string, I should be creating an array or a hash, adding each interest as I find it, then storing each of these in an array or hash? Thanks so much for the help.</p>
  
  <pre><code>def getMatchedUsers
    matched_user_html = nil
    combined_properties = nil
    online_user_list = User.logged_in.all
      shared_interest = false
      online_user_list.each do |n| # for every online user
        combined_properties = nil
        if n.email != current_user.email # that is not the current user 
        current_user.properties.each do |o| # go through all of the current users properties
          n.properties.each do |p| # go through the online users properties
                if p.interestname.eql?(o.interestname) # if the online users property matches the current user
                    shared_interest = true
                    if combined_properties == nil
                      combined_properties = o.interestname
                    else
                      combined_properties = combined_properties + ", " + o.interestname
                    end
                end
            end
            if shared_interest == true
                  matched_user_html = n.actualname + ": " + combined_properties
              end
        end
      end
      end
      return matched_user_html
    render :nothing =&gt; true
  end
  </code></pre>