`
zzhang
  • 浏览: 17703 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

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.

 

分享到:
评论

相关推荐

    Guide to Scientific Computing in C++

    2.6.4 Tip 4: Never Ending while Loops . . . . . . . . . . . 2.6.5 Tip 5: Comparing Two Floating Point Numbers . . . . 2.7 Exercises . . . . . . . . . . . . . . . . . . . . 3 File Input and Output . ....

    MPEG4 C++解码

    Never use build-in types, e.g., “int”, “char.” 5. Observe the coding style of the original code. Use Tab, Space and Indention appropriately. 6. Obey the Hungarian naming convention. In the ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: The TFlexPanel.FindControlAtPoint method maked virtual to realize RealTime-capability when on mouse cursor moving the flex-object search not occurs. - FIX: After deleting the selected points ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Another useful rule of thumb: it's typically not cost effective to inline functions with loops or switch statements (unless, in the common case, the loop or switch statement is never executed)....

    年高考英语热点题型和提分秘籍专题03形容词和副词.doc

    - 题目中的句子“The state-run company is required to make its accounts as ___________ as possible for its staff to monitor the use of money.”,要求公司让账目尽可能透明以便员工监督资金使用。...

    Squid中文权威指南

    译者序: 本人在工作中维护着数台Squid服务器,多次参阅Duane Wessels(他也是Squid的创始人)的这本书,原书名是"Squid: The Definitive Guide",由O'Reilly出版。我在业余时间把它翻译成中文,希望对中文Squid用户...

    pid调试经验

    NEVER use damaged blades. For SAFETY reason, the default gains are set to small value. You HAVE TO increase the gains before you can expect any control responses. This tutorial is valid for all multi ...

    Troubleshooting.Xcode.1484215613

    Know when you should never use Storyboards for your OS X application. Discover several workarounds you can use to bypass some of the hardest problems you may face. Know how to use scripts to automate ...

    Digging into WordPress.pdf

    1.2.1 So, You’ve Never Heard of WordPress ..................12 1.2.2 One Template, Many Pages ..........................................................13 1.2.3 Powerful, Flexible and Extensible .......

    smali2java.jar

    Why not to use dex2jar? I have never told about it. Dex2jar is a good utility and smali2java is another good utility. You can use dex2jar or smali2java or both. Technical questions Does smali2java ...

    微软内部资料-SQL性能优化5

    If all columns needed for the query are in the index, SQL Server never needs to access the data pages. If even one column in the query is not part of the index, the data rows must be accessed. The ...

    九年级英语复习PPT课件.pptx

    5. **疑问词+不定式** (how to use): "how to use" 表示“如何使用”,在句中作宾语。 6. **动名词** (practicing reading): "practice reading",动词 practice 后接动名词作宾语。 7. **不定式** (to take): ...

    Howoftendoyouexercise单元归纳及习题.pdf

    频度副词用于表达动作发生的频率,如 always, usually, often, sometimes, seldom, hardly ever, rarely, never。它们按频率大小排列,并且有不同的位置规则: 1. 在 be 动词之后。 2. 在第一个动词或情态动词之后。...

    polycom宝利通视频会议软件3.9 2018

    If you do not agree to the terms of this Agreement, your use is prohibited and you may not install or use the SOFTWARE PRODUCT. The SOFTWARE PRODUCT is protected by copyright laws and ...

    初二英语期末复习重点.doc

    此外,a bit、a bit of、a little和not a bit/not at all等表达方式也需掌握。 9. **It is + adj + to do sth**、**It is + adj + for sb. + to do sth** 和 **It is + adj + of sb. + to do sth**:这三个结构用于...

    Lean Python(Apress,2016)

    Learn only the essential aspects of Python without cluttering up your mind with features you may never use. This compact book is not a “best way to write code” type of book; rather, the author goes ...

    APPLIED NUMERICAL METHODS USING MATLAB.pdf

    We never deny that detailed knowledge about the algorithm (engine) of the program (car) is helpful for getting safely to the solution (destination); we only imply that one-time users of any MATLAB ...

    NativeXml-master

    fixed major bug where parser does not use ansi + 65001 codepage but really utf8, so the writer also uses utf8 (and added Test14 to check) * Added speed comparison between old TNativeXml and new ...

Global site tag (gtag.js) - Google Analytics