never use not + not.

A bug take a long time to find out.

I had a method like:

 

 def file_not_exsit_with?(url)
   require 'open-uri'
   return open(url).read =~ /^Status: 500 Internal Server Error/
 rescue
   puts "#{url} not exists!".center(66, "=")
   # return true # I missed this line
 end
 

And use it like this:

 

unless file_not_exsit_with?(file_url)
  # ...
end

 

I missed "return true", and because the bad use of unless and not, it is difficult to find.

 

Learned:

Never use not + not.

 

你可能感兴趣的:(r)