uniq_by.rb 561 字节
Newer Older
1
class Array
2 3 4
  # *DEPRECATED*: Use +Array#uniq+ instead.
  #
  # Returns a unique array based on the criteria in the block.
5
  #
V
Vijay Dev 已提交
6
  #   [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
7
  #
8
  def uniq_by(&block)
A
Alexey Gaziev 已提交
9
    ActiveSupport::Deprecation.warn 'uniq_by is deprecated. Use Array#uniq instead', caller
10
    uniq(&block)
11 12
  end

13 14 15
  # *DEPRECATED*: Use +Array#uniq!+ instead.
  #
  # Same as +uniq_by+, but modifies +self+.
16
  def uniq_by!(&block)
A
Alexey Gaziev 已提交
17
    ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead', caller
18
    uniq!(&block)
19 20
  end
end