diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb new file mode 100644 index 0000000000..b7ee00742a --- /dev/null +++ b/activesupport/lib/active_support/core_ext/array/random_access.rb @@ -0,0 +1,12 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module Array #:nodoc: + module RandomAccess + # Return a random element from the array. + def rand + self[Kernel.rand(length)] + end + end + end + end +end