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

Google sheets equipment borrowing system -

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

c# - Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>' -