module Enumerable
def excluding(*elements)
{foo: 1, bar: 2, baz: 3}.excluding :bar
# => ["David", "Rafael"]
["David", "Rafael", "Aaron", "Todd"].excluding %w[ Aaron Todd ]
# => ["David", "Rafael"]
["David", "Rafael", "Aaron", "Todd"].excluding "Aaron", "Todd"
Returns a copy of the enumerable excluding the specified elements.
def excluding(*elements) elements.flatten!(1) reject { |element| elements.include?(element) } end