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.
分享到:
相关推荐
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 . ....
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 ...
- 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 ...
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)....
- 题目中的句子“The state-run company is required to make its accounts as ___________ as possible for its staff to monitor the use of money.”,要求公司让账目尽可能透明以便员工监督资金使用。...
译者序: 本人在工作中维护着数台Squid服务器,多次参阅Duane Wessels(他也是Squid的创始人)的这本书,原书名是"Squid: The Definitive Guide",由O'Reilly出版。我在业余时间把它翻译成中文,希望对中文Squid用户...
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 ...
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 ...
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 .......
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 ...
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 ...
5. **疑问词+不定式** (how to use): "how to use" 表示“如何使用”,在句中作宾语。 6. **动名词** (practicing reading): "practice reading",动词 practice 后接动名词作宾语。 7. **不定式** (to take): ...
频度副词用于表达动作发生的频率,如 always, usually, often, sometimes, seldom, hardly ever, rarely, never。它们按频率大小排列,并且有不同的位置规则: 1. 在 be 动词之后。 2. 在第一个动词或情态动词之后。...
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 ...
此外,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**:这三个结构用于...
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 ...
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 ...
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 ...