我有一个这样的数组:
array = [{"id"=>"id1", "email"=>"name@organization.com", "sess"=>"sess1"},
{"id"=>"id2", "email"=>"name@organization.com", "sess"=>"sess2"},
{"id"=>"id3", "email"=>"name@organization.com", "sess"=>"sess2"},
{"id"=>"id4", "email"=>"name@organization.com", "sess"=>"sess3"},
{"id"=>"id5", "email"=>"name@organization.com", "sess"=>"sess2"},
{"id"=>"id6", "email"=>"name@organization.com", "sess"=>"sess3"},
{"id"=>"id7", "email"=>"name@organization.com", "sess"=>"sess2"},
{"id"=>"id8", "email"=>"name@organization.com", "sess"=>"sess5"},
{"id"=>"id9", "email"=>"name@organization.com", "sess"=>"sess2"},
{"id"=>"id10", "email"=>"name@organization.com", "sess"=>"sess2"},]
我怎样才能以简洁的方式返回所有不同出现的“sess”而不重复?:
["sess1", "sess2", "sess3", "sess5"]
我已经开始编写一个循环,它遍历所有元素并在每次“sess”值已经存在时构建一个新的哈希检查,但我确信在 Ruby 中一定有更好的方法。