class Enumerator

Public Instance Methods

with_else(f, *args) { |*i| ... } click to toggle source
# File lib/with_else.rb, line 2
def with_else(f, *args)
  if block_given?
    each {|*i| yield(*i)}
    f.call(*args)
  else
    Enumerator.new do |y|
      each do |*i|
        a = (i.size <= 1) ? i[0] : i
        y << a
      end
      f.call(*args)
    end
  end
end