ruby on rails - Comparing an array of users to an array of structs with user object as attribute, and returning matches in another array of structs -


I have users who are friends. Call us to this array:

  friend  

Then I have an array of strokes. Each structure has a user object as a feature (it also has a rank attribute). To add some context, here's what the structure class looks like:

  class leaders < Struct.new (: Rank, User); End  

call us this array of strokes:

  all_leaders_plus_rank  

I compare friends Matching and all_leaders_plus_rank , and all_leaders_plus_rank are called friendly_liders in a new array of strokes.

  friendly_layer = all_leaders_plus_rank.select do | Lpr | Friends.include? (Lpr.user) Expires  

Comments