aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/enumerable.rb
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-10-14 03:26:16 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-10-14 03:26:16 +0000
commite9df41a75929ad72608eb9a2d3757b200ba1d23d (patch)
tree1bfd94a2ed8100557723c3912da0e7c0ff61d515 /activesupport/lib/active_support/core_ext/enumerable.rb
parent276f14444c2cb840f7076751438dba78ce291a51 (diff)
downloadrails-e9df41a75929ad72608eb9a2d3757b200ba1d23d.tar.gz
rails-e9df41a75929ad72608eb9a2d3757b200ba1d23d.tar.bz2
rails-e9df41a75929ad72608eb9a2d3757b200ba1d23d.zip
Added Enumerable#first_match
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/enumerable.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
new file mode 100644
index 0000000000..497ca52c2d
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -0,0 +1,9 @@
+module Enumerable
+ def first_match
+ match = nil
+ each do |items|
+ break if match = yield(items)
+ end
+ match
+ end
+end \ No newline at end of file