Report abuse


			
class Proxy
  def initialize(target)
    @target = target
  end
  private
  def method_missing(method, *args)
    if block_given?
      @target.send(method, *args)  { |*block_args| yield(*block_args) }
    else
      @target.send(method, *args)
    end
  end
end

a = [1, 2, 3]
Proxy.new(a).each_with_index {|x,i| puts "#{i}: #{x.inspect}"}