Раздел «Язык Ruby».ClousureSamples:

Clousure Samples

def hello
  hi = 'hi'
  $h = lambda {
    puts "In block: " + hi
  }
  hi = 'hello'
end

def hi
  'good buy!'
end

hello

$h[]

hi = 'good buy!!'

puts eval('hi', $h)

# not related to clousure, but interesting
puts hi()
puts hi

-- ArtemVoroztsov - 19 Oct 2007