diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-05-16 15:20:52 -0300 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-05-16 22:23:44 +0200 |
commit | 821e15e5f2d9ef2aa43918a16cbd00f40c221e95 (patch) | |
tree | deb326567a2f383afd37b20f231f490d67c8ac82 /activesupport/lib/active_support | |
parent | 64d109e3539ad600f58536d3ecabd2f87b67fd1c (diff) | |
download | rails-821e15e5f2d9ef2aa43918a16cbd00f40c221e95.tar.gz rails-821e15e5f2d9ef2aa43918a16cbd00f40c221e95.tar.bz2 rails-821e15e5f2d9ef2aa43918a16cbd00f40c221e95.zip |
Change on Array extension from rand => random_element [#4555 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/random_access.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb index 343003f6f7..5338836b29 100644 --- a/activesupport/lib/active_support/core_ext/array/random_access.rb +++ b/activesupport/lib/active_support/core_ext/array/random_access.rb @@ -1,6 +1,16 @@ class Array + # This method is deprecated because it masks Kernel#rand within the Array class itself, + # which may be used by a 3rd party library extending Array in turn. See + # + # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555 + # + def rand # :nodoc: + ActiveSupport::Deprecation.warn "Array#rand is deprecated, use random_element instead", caller + random_element + end + # Returns a random element from the array. - def rand + def random_element self[Kernel.rand(length)] end end |