Sha256: 5a0db0757d45f45ad9e463b5ac5e9bd0dc785b1402df680b416d71eb5eddf0de
Contents?: true
Size: 776 Bytes
Versions: 5
Compression:
Stored size: 776 Bytes
Contents
#-- # Author:: Tyler Rick # Copyright:: Copyright (c) 2009, Tyler Rick # License:: Ruby License # Submit to Facets?:: Yes # Developer notes:: # History:: #++ module Enumerable # def reject! # if self.is_a? Range # to_a.reject! { yield } # else # raise NoMethodError # end # end def select! reject! { |x| !yield(x) } end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'spec' describe 'Enumerable#select!' do it 'reject!' do a = %w[a b c d] a.reject! {|e| e =~ /[ab]/}.should == a a.should == %w[c d] end it 'select!' do a = %w[a b c d] a.select! {|e| e =~ /[ab]/}.should == a a.should == %w[a b] end end =end
Version data entries
5 entries across 5 versions & 1 rubygems