From: Dave Thomas Date: 2003-03-13T14:46:49+09:00 Subject: Re: next iteration within a block On Wednesday, Mar 12, 2003, at 23:17 US/Central, Wojciech Kaczmarek wrote: > What is the most short/elegant way of ending the current iteration > within a block? My first thought was that `next' will break the > iteration and last evaluated expr will be returned to the caller, but > surprisingly `nil' is returned this way, so we have (Ruby 1.6.8): > > ['bar','quux'].map {'foo'; next; 42} > => [nil, nil] Try [1,2].map {|i| next 'b' if i < 2; 'a'} => ["b", "a"] Cheers Dave