Add Enumerable#exclude? to bring parity to Enumerable#include? and av…
…oid if !x.include?/else calls [DHH]
You'd wonder why this wasn't just part of Ruby. ;-)
I dig it.
Thanks for making this popular, I was already using it for a while, after drawing inspiration from the whole Core Extension module of Rails.
I also like:
Actually, I disagree. On the same basis you should add invalid? to ActiveRecord, not_ssl? to the Request class etc. Ruby has a very short not operator (!) -- why not use it?
Yes, I know that ruby has "select" and "reject" which can be defined one using the other; still I think these are somewhat OK whereas "exclude?" (which is really "not_include?") is not needed.
One of the major things that makes Ruby cool is readability, and the addition of Enumerable#exclude? certainly makes for more readability, and it does something we need all the time.
Seems to me that unless x.include?( obj ) is actually more clear in this case... but no harm done.
unless x.include?( obj )