B
Benjamin Ter kuile
I want to create a conditional mathematical function as a lambda
structure. Therefore it may be the case that inside an iterative loop,
the result of the function is known and should be returned. By
implementing this it causes trouble. The test code I created looks like:
func = lambda do
for z in [1,2,3]
return 2
end
"something"
end
puts func.call
puts "after call"
This results in a LocalJumpError (Ruby 1.8.6 and 1.8.7). In ruby 1.9 it
works as expected. Is there a proper way of creating a function like
this in ruby < 1.9?
Regards,
Benjamin
structure. Therefore it may be the case that inside an iterative loop,
the result of the function is known and should be returned. By
implementing this it causes trouble. The test code I created looks like:
func = lambda do
for z in [1,2,3]
return 2
end
"something"
end
puts func.call
puts "after call"
This results in a LocalJumpError (Ruby 1.8.6 and 1.8.7). In ruby 1.9 it
works as expected. Is there a proper way of creating a function like
this in ruby < 1.9?
Regards,
Benjamin