Sunday, May 19, 2013

Lost minus

def quiz
    a = Proc.new do
        return 1
    end
    
    b = Proc.new do
        return -1
    end
    
    c = Proc.new do |x, y|
        return x.call * y.call
    end
    
    return c.call(a,b)
end

puts quiz
This Ruby script prints "1\n". Why?

No comments:

Post a Comment