From: "David A. Black" Date: 2004-08-20T12:13:25+09:00 Subject: Re: MatchData.each method.....no "next" ? Hi -- On Fri, 20 Aug 2004, Zach Dennis wrote: > I've got a block of code: > > process = proc { |str,val| > process_hsh = { "String" => true , "Fixnum" => true } > re = /\((.*)\)|\{(.*)\}/; > m = str.scan( re ) > if( process_hsh["#{val.class.to_s}"] ) then > m.each{ |v| > next if( not v); #<-----------------THIS IS THE CULPRIT [...] > Does MatchData not take advantage of iterating via "next" ? Thanks, m isn't a MatchData object; it's an Array (returned by scan). 'next' definitely works; if it doesn't move to the next iteration, then "not v" is not true. I think you may be testing for empty strings with 'not', which doesn't work because "" is true. If that turns out to be the problem, you can do: next if v.empty? David -- David A. Black dblack@wobblini.net