From: Clement Ow Date: 2008-05-14T13:38:23+09:00 Subject: Re: Handling of arrays Jes炭s Gabriel y Gal叩n wrote: > > Hope this helps, > > Jesus. thanks Jesus, that was really helpful! However I altered the code alil cause ruby rendered an error to me saying that it cant convert Array into string (hmmm, dunno if that's normal) for this line(suppose it's for the arrays in the hash, exceptions_by_path): >files = exceptions_by_path.inject(Dir.glob("#{path}/*")) {|result, ex| result.reject{|x| x =~ Regexp.new(ex)}} So i decided to name my arays in the hash, file_exception[0], file_exception[1] ... and used this instead with an incremental value: >>i = 0 >> src1 = $file_exception[i].inject(Dir.glob(src)) {|result, >>ex|result.reject{|x| x =~ Regexp.new(ex)}} >> i = 1 + i But i had the problem of accidentally keyin in the a wrong path name and nothing was shown for the 2nd source path.(Only after troubleshooting for 1 whole hr did i realise) So is there any way where by we can have a condition something like, if result == nil puts "wrong pathname"(just an idea, cos i tried and it doesnt work) And btw dont get me wrong, Struct is sweet too, just that i didnt want to have a fixed number of exceptions for each path. ;) Thanks again. -- Posted via http://www.ruby-forum.com/.