On Tue, Jun 2, 2009 at 10:53 PM, Robert Dober <robert.dober / gmail.com> wrot=
e:
> On Tue, Jun 2, 2009 at 10:06 PM, Benjamin Ter kuile <bterkuile / gmail.com>=
 wrote:
>> 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 =3D lambda do
>> =A0for z in [1,2,3]
>> =A0 =A0return 2
>> =A0end
>> =A0"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?
> Yes there is!
> Strange you did not ask how though ;)
> Well I'll tell you anyway...
>
> s/return/break/
>
But why did you put something there, now it does not work anymore :(
Sorry did not see

lambda f do
 ...each do
     break 2
 end ||
  something
end


> HTH
> Robert
>>
>> Regards,
>>
>> Benjamin
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>
>
>
>
> --
> Toutes les grandes personnes ont d=92abord =E9t=E9 des enfants, mais peu
> d=92entre elles s=92en souviennent.
>
> All adults have been children first, but not many remember.
>
> [Antoine de Saint-Exup=E9ry]
>



--=20
Toutes les grandes personnes ont d=92abord =E9t=E9 des enfants, mais peu
d=92entre elles s=92en souviennent.

All adults have been children first, but not many remember.

[Antoine de Saint-Exup=E9ry]