$exponent = 0
def power
  proc {|base| base**$exponent}
end

$exponent = 2
square = power
$exponent = 3
cube = power
a = square.call(11)     # Wrong! Result is 1331
b = square.call(5)      # Wrong! Result is 125
# The above two results are wrong because the CURRENT value
# of $exponent is being used. This would be true even if it
# had been a local variable that had gone out of scope (e.g.,
# using define_method).
c = cube.call(6) # Result is 216
d = cube.call(8) # Result is 512

