From: Wojciech Kaczmarek Date: 2003-03-13T14:17:29+09:00 Subject: next iteration within a block 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] instead of two foos in an array. In a real code, when I don't want to make the content of a block a multibranched if statement (or something similar), I use something like that: #v+ aMethod do |item| catch :next do #blah throw :next, special_result if special_condition #blahblah default_result end end #v- ...but maybe there's something better? (I really don't think I found a bug regarding `next' behaviour :) -- We demand rigidly defined areas of doubt and uncertainty!