Closure Example def stack_closures stack = [] push = lambda{|x| stack.push(x)} pop = lambda{stack.pop} top = lambda{stack[-1]} return push, pop, top end pusher, popper, topper = stack_closures() pusher.call(10) pusher.call(20) popper.call # => 20 topper.call # => 10 Encapsulated local variables