From: Niko Schwarz Date: 2001-11-14T22:13:20+09:00 Subject: [ruby-talk:25168] Re: exiting blox Dave Thomas wrote: > Niko Schwarz writes: > >> Hi there, >> is there a way to exit a block before time? >> like: >> >> field.each { |el| >> if(el.alsacian?) >> break #no, dont want anymore >> else >> puts el >> end >> } > > Doesn't 'break' work? Unfortunately not, i tried this: ,----[ eval.rb ] | ruby> 1.upto(5) { |i| | ruby| if i.divmod(2) == 0 then | ruby| break | ruby| end | ruby| puts i | ruby| } | 1 | 2 | 3 | 4 | 5 | 1 `------ The break doesnt seem to do anything, whats happening here? regards, nick -- QUOTE OF THE DAY: `