check if array of arrays contains some array

This question already has an answer here:

  • Check if a value exists in an array in Ruby 23 answers

  • Ruby's #include? method can be used here:

    arr = [[1, 2], [3, 4], [4, 5]]
    arr.include?([1, 2])
    # => true
    

    Hope this helps!


    Just use bigarray.include? smallarray bigarray.include? smallarray . It's the same way you'd check for membership with any other list. Example

    链接地址: http://www.djcxy.com/p/25672.html

    上一篇: 在Array中查找值

    下一篇: 检查数组数组是否包含某个数组