本文介绍了len(x)更好或x NEQ“更好的CFML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此
<cfif len(x)>
或
<cfif x NEQ "">
哪一个更有效率和可读性?函数调用与比较空字符串?
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".
我还使用ColdFusions宽松的布尔值来处理很多事情:
I also use ColdFusions loose boolean values for lots of things like in addition:
if(a + b){
...
}
这篇关于len(x)更好或x NEQ“更好的CFML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!