3 ms·
> then I realized that Ruby isn't quite like them either. I am curious. How does Ruby's closure differ from Scheme's?
by irahul 15y ago
> then I realized that Ruby isn't quite like them either.
I am curious. How does Ruby's closure differ from Scheme's?
- spacemanaki 15y agoTo be honest, I'm not really sure. I think it's a superficial difference. When I put this into a Ruby 1.9.2 REPL def foo (n) lambda {|i| n += i } end I expected to be able to do this: acc = foo(0) acc(1) But instead have to do acc.call(1) Maybe there's another way... Edit: oops you pointed out this example in another comment, sorry! Is there no way for the returned lambda to "feel" like a regular function?
- deleted 15y ago[deleted]