什么是最好的方法:我有两个数组:
a=[['a','one'],['b','two'],['c','three'],['d','four']]
Run Code Online (Sandbox Code Playgroud)
和 b=['two','three']
我想删除a
包含元素的嵌套数组b
,以获得:
[['a','one']['d','four']
Run Code Online (Sandbox Code Playgroud)
谢谢.
Sim*_*tti 17
a = [['a','one'],['b','two'],['c','three'],['d','four']]
b = ['two','three']
a.delete_if { |x| b.include?(x.last) }
p a
# => [["a", "one"], ["d", "four"]]
Run Code Online (Sandbox Code Playgroud)