On 2002.05.18, Paul Graham <spam / bugbear.com> wrote: > I'm writing something showing how you'd write the same > simple program in various different languages. I'd > appreciate it if some Ruby expert could tell me the > canonical way to write in Ruby what you would express > in Scheme as > > (define (foo x) (lambda (y) (set! x (+ x y)))) > > or Perl 5 as > > sub foo { > my ($n) = @_; > return sub {return $n += shift}} I think Proc is the mechanism Ruby uses to offer closures. My guess: def foo(n) Proc.new { |arg| n += arg } end bar = foo(5) # => #<Proc:0x4027589c> bar.call(10) # => 15 -- Dossy -- Dossy Shiobara mail: dossy / panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)