我有以下数组:
array = [{"email"=>"[email protected]", "name"=>"Test"},
{"email"=>"[email protected]", "name"=>"Test A"},
{"name"=>"Test B", "email"=>"[email protected]"},
{"email"=>"[email protected]", "name"=>"Test C"},
{"name"=>"Test D", "email"=>"[email protected]"},
{"email"=>"[email protected]"},
{"name"=>"Test F", "email"=>"[email protected]"}]
我有一个“黑名单”电子邮件列表,例如:
blacklist = ["[email protected]"]
我想做这样的事情:
array - blacklist
# => should remove element {"email"=>"[email protected]", "name"=>"Test C"}
当然有一种性感的Ruby方式可以用.select或者其他东西来做这件事,但是我还没弄清楚。我试过这个无济于事:
array.select {|k,v| v != "[email protected]"} # => returns array without any changes