From: beatmadsen@... Date: 2019-08-03T20:40:19+00:00 Subject: [ruby-core:94133] [Ruby master Feature#16039] Array#contains? to check if one array contains another array Issue #16039 has been updated by ahvetm (Erik Madsen). I think this is a great proposal in terms of having one of those nice, useful methods easily available directly on the class you're interacting with, similar to `Array#last` which can quite verbose in other languages. I would propose the name `#include_all?` or something similar to make it obvious that you're comparing it with another array. ---------------------------------------- Feature #16039: Array#contains? to check if one array contains another array https://bugs.ruby-lang.org/issues/16039#change-80382 * Author: cha1tanya (Prathamesh Sonpatki) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I woud like to propose `Array#contains?` which will check if the one array is part of another array. Implementation can be as follows: ``` def contains?(other) (other - self).empty? end ``` Some test cases: ``` [1, 2, 3].contains?([2, 3]) => true [1, 2, 3].contains?([]) => true [1, 2, 3].contains?([1, 2, 3, 4]) => false [].contains?([]) => true [].contains?([1, 2, 3, 4]) => false ``` -- https://bugs.ruby-lang.org/ Unsubscribe: