From e9df41a75929ad72608eb9a2d3757b200ba1d23d Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Fri, 14 Oct 2005 03:26:16 +0000 Subject: Added Enumerable#first_match git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/enumerable.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/enumerable.rb (limited to 'activesupport/lib/active_support/core_ext/enumerable.rb') 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 -- cgit v1.2.3