End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Enumerable#grep_v
enum.grep_v(pattern) → array
enum.grep_v(pattern) { |obj| block } → array
enum.c
View on GitHub ↗
static VALUE
enum_grep_v(VALUE obj, VALUE pat)
{
return enum_grep0(obj, pat, Qfalse);
}
Inverted version of Enumerable#grep. Returns an array of every element in enum for which not Pattern === element.
Example
(1..10).grep_v 2..5 #=> [1, 6, 7, 8, 9, 10] res =(1..10).grep_v(2..5) { |v| v * 2 } res #=> [2, 12, 14, 16, 18, 20]