Re:... because Ruby isn't terse enough yet
by neelesh on Sunday October 28, 2007 @11:02PM
(#73622)
That holds true for the given ruby implementation as well, since n is incremented only in the scope of foo and not in the calling scope.
def foo (n)
lambda {|i| n += i }
end
n=5
a = foo(n)
puts a.call(3) #prints 8
puts n # still prints 5. n is not incremented
I agree that the python one is strictly not according to the problem definition, but for all practical purposes both python equivalents are the same, aren't they? or am I missing something?
def foo (n)
endn=5
a = foo(n)
puts a.call(3) #prints 8
puts n # still prints 5. n is not incremented
I agree that the python one is strictly not according to the problem definition, but for all practical purposes both python equivalents are the same, aren't they? or am I missing something?