aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/random_access.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array/random_access.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/array/random_access.rb12
1 files changed, 12 insertions, 0 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
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