From: "Ara.T.Howard" Date: 2005-10-31T10:45:57+09:00 Subject: Re: Very useful... 'break' accepts an argument On Mon, 31 Oct 2005, Eric Mahurin wrote: > Unfortunately the base iterators return the object they are iterating over > instead of nil like the non-iterator loops (while, until, loop). For the > non-iterator loops nil can mean terminate normally if you use break with a > value (non-nil). For iterator loops you have to do the opposite - break with > a value is of little use. > > I discussed the problem here: > > http://rcrchive.net/rcr/show/305 valid point. i use the following pattern for those situations: config = catch('config') do search_path.each |dir| candidate = File::join dir, "#{ $0 }.conf" throw 'config', candidate if test ?e, candidate end nil end unless config warn{ "using default config" } config = default_config end it would be nice to do this more compactly. cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================