From c30c1808c0da2bfd34baf613fd8e1a4b685e8d94 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 15 Sep 2007 22:56:25 +0000 Subject: Missing file from previous patch git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7490 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/array/random_access.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/array/random_access.rb (limited to 'activesupport/lib/active_support') 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 -- cgit v1.2.3