From: Clement Ow Date: 2008-05-21T17:33:39+09:00 Subject: Re: Local Jump Error Sebastian Hungerecker wrote: > > Find always > returns nil. So you can't call each on the return value of find and > using it > as the default value for inject makes no sense (as it's the same as > inject(nil). > Find.find(src1).each do |file| > can be replaced with > Find.find(src1) do |file| > > The inject could be replaced with: > src1 = [] > Find.find(src) do |file| > src1 << file unless $file_exception[i].any? do |x| > /#{x}/i =~ File.basename(file) > end > end > > or: > > require 'enumerator' > src1 = Find.enum_for(:find, src).reject do |file| > $file_exception[i].any? do |x| > /#{x}/i =~ File.basename(file) > end > end > # (both untested) > > HTH, > Sebastian if $file_exception[i] != nil Find.find($source) do |file| src1 << file unless $file_exception[i].any? do |x| /#{x}/i =~ File.basename(file) end end else src1 = $source end i = i + 1 Find.find(src1).each do |file| : : end Apparently now the code raises an error at the last Find.find(src1).each do |file|, saying that there is a LocalJumpError. > Nope. The block passed to find is not a filter. Find takes an argument > as well > as a block and it executes the block for every file it finds. If Find takes arguments, why it doesnt execute this block of code then? -- Posted via http://www.ruby-forum.com/.