我需要检查一个数组,看看它是否只包含另一个数组的某些值。
我可以想办法做到这一点使用方法map和select,然后通过数组迭代includes?但这会从效率远。
values = ['2','4','5'] # return true if the array only contains these values...
a = ['1', '2', '3']
b = ['1', '2', '4']
c = ['2', '4']
d = ['4', '5']
def compare(checked_array, standard)
# Do something
end
Run Code Online (Sandbox Code Playgroud)
所以,为了我的目的,输出应该是,