Sha256: a3d4645cd0044c6c21a604086840f8b61fe71cbe9b959f408eb87c839bc6453c
Contents?: true
Size: 636 Bytes
Versions: 8
Compression:
Stored size: 636 Bytes
Contents
unless [1,2].uniq{}.size == 1 require 'backports/tools' class Array def uniq_with_block return uniq_without_block unless block_given? h = {} each do |elem| h[yield(elem)] ||= elem end h.values end Backports.alias_method_chain self, :uniq, :block end end unless [1,2].uniq!{} require 'backports/tools' class Array def uniq_with_block! replace self if frozen? # force error return uniq_without_block! unless block_given? u = uniq{|e| yield e} replace u unless u.size == size end Backports.alias_method_chain self, :uniq!, :block end end
Version data entries
8 entries across 8 versions & 1 rubygems