This project is archived and is in readonly mode.

#1950 ✓wontfix

ActiveSupport: alternative Block execution on empty Enumerable

Reported by Paul | February 12th, 2009 @ 10:21 AM | in 2.x

i did not find an easy way to specify an alternative action when an iterator had nothing to iterate over.

i am using this for now:

module Enumerable def else(&block)

self.respond_to?('empty?') && self.empty? ? yield : self



in color :)

maybe this is usable in general...

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>