len(x) 更好或 x NEQ“";CFML 更好? [英] len(x) better or x NEQ "" better in CFML?
本文介绍了len(x) 更好或 x NEQ“";CFML 更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个
<cfif len(x)>
或者
<cfif x NEQ "">
哪一个更高效、更易读?函数调用 vs 比较空字符串?
Which one is more efficient and readable? Function call vs comparing empty string?
推荐答案
我用:
if(len("String"));
我认为代码更简洁,而且他们喜欢说富有表现力".使用这种语法,您在代码中所说的是如果此字符串有长度",则执行此操作,而相反,您的代码是说字符串的长度是否为空白字符串,请执行此操作".
I think the code is much cleaner and as they like to say "expressive". With this syntax what you are saying with the code is "if this string has a length" do this where with the opposite your code is "saying if the length of the string is a blank string do this".
我还使用 ColdFusion 的松散布尔值来处理很多事情,例如:
I also use ColdFusions loose boolean values for lots of things like in addition:
if(a + b){
...
}
这篇关于len(x) 更好或 x NEQ“";CFML 更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文