is there way delete hash item within select? want check if file exists in directory , if does, remove hash.
hash = {"http://s3-us-west-2.amazonaws.com/packages/ics/ics_4.0.0.tar.gz"=>"5103909285b549eda0b6a13dd503790a", ...} hash.select |k,v| if file.file?("#{k[/[^\/]+$/]}") # remove hash end end
you cannot delete element in select, delete_if
choice.
hash.delete_if { |k,_| file.file?("#{k[/[^\/]+$/]}") }
update:
hash_copy = hash.dup hash.select |k,v| if file.file?("#{k[/[^\/]+$/]}") hash_copy.delete(k) ...... end end
Comments
Post a Comment