Issue #6150 has been updated by sunaku (Suraj Kurapati).


I'd rather not wait 2+ years for this issue to be resolved by making this feature dependent on Ruby 2.0's named parameters feature.  I'm also not fond of passing an options hash to grep() because, although you say it has nothing to do with Ruby vs. Rails, in my limited experience with Ruby programming, it's uncommon for Ruby core API to accept options hash.  In contrast, it's more common to see Rails core API accept options hash.

So I urge you to reconsider my original proposal to add a new grep_v() method.  Precedents can be found throughout the FileUtils standard library:

* ln() vs ln_s() vs ln_sf()
* mkdir() vs mkdir_p()
* cp() vs cp_r()
* rm_f() vs rm_r() vs rm_rf()
* chmod() vs chmod_R()
* chown() vs chown_R()

Notice how these are all separate methods; they're not ln(..., :symbolic => true) and mkdir(..., :prefix => true) and so on.

Thanks for your consideration.
----------------------------------------
Feature #6150: add Enumerable#grep_v
https://bugs.ruby-lang.org/issues/6150#change-25331

Author: sunaku (Suraj Kurapati)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Please add a grep_v() method to Enumerable that behaves like the opposite of grep().

For example, if Enumerable#grep() was implemented like this:

module Enumerable
  def grep pattern
    select {|x| pattern =~ x }
  end
end

then Enumerable#grep_v() would be implemented like this (select becomes reject):

module Enumerable
  def grep_v pattern
    reject {|x| pattern =~ x }
  end
end


The method name "grep_v" comes from the "-v" option passed to grep(1).

Thanks for your consideration.


-- 
http://bugs.ruby-lang.org/