ruby - Delete file from path value stored in array method fails if file is not present -


i have dynamically generated array of file paths may this:

paths = ["/lib/my_folder/foo", "/lib/my_folder/bar", "/lib/my_folder/baz", ...] 

so want do:

for path in paths |path|   file.delete(path) #if file exists end 

this failing element in array points file no longer there.

i tried:

for path in paths   if !path.blank?     file.delete(path)   end end 

but still fails no such file or directory... error msg.

how can go writing loop dele element(s) left in array without failing?

paths.each { |path| file.delete(path) if file.exists?(path) } 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -