require 'set'games = [["Alice", "Bob"], ["Carol", "Ted"], ["Alice", "Mallory"], ["Ted", "Bob"]]p players = games.inject(Set.new) { |set, game| game.each { |p| set << p }; set }# => #p players << "Ted"# => #