什么整数被认为是“真实的”?在 ColdFusion “if” 中陈述

发布于 2024-12-29 09:35:38 字数 710 浏览 3 评论 0原文

可能的重复:
ColdFusion 认为“虚假”的值有哪些”和“真实”?

在 ColdFusion 中,在 if 中哪些整数被视为 true 以及哪些整数被视为 false 陈述?我知道 1true0false,但是是这样吗?

例如,如果知道我可以对查询数据结构的记录计数执行 if 以确定查询中是否至少有一条记录,那就太好了。例如,假设我们的查询名为 employees

<cfif variables.employees.recordCount>
    There ARE employees.
<cfelse>
    There ARE NO employees.
</cfif>

如果记录数为 2 条,是否会显示“There ARE员工”语句?

Possible Duplicate:
What are all the values that ColdFusion considers “falsy” and “truthy”?

In ColdFusion, what integers are considered true and what integers are considered false in an if statement? I know that 1 is true and 0 is false, but is this it?

For example, it would be nice to know that I can do an if on a query data structure's record count to determine if the query has at least one record in it. For example, let's say our query is called, employees.

<cfif variables.employees.recordCount>
    There ARE employees.
<cfelse>
    There ARE NO employees.
</cfif>

Would the statement "There ARE employees" be displayed if the record count was, say, 2?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

数理化全能战士 2025-01-05 09:35:39

任何非零数都是真的。只有 0 才会返回 false。

Any non zero number is true. Only 0 will return false.

末が日狂欢 2025-01-05 09:35:39

cfif 标记内的表达式必须计算为布尔值(真/假)。布尔值表示为“true”或“false”、“yes”或“no”、“0”或任何数字。

参考

所以看起来 0 代表 false,或者其他任何值代表 true整数。

The expression inside the cfif tag must evaluate to a Boolean value (a true/false). Boolean values are represented as either "true" or "false", "yes" or "no", or "0" or any number.

Reference

So it looks like 0 is for false, or anything else for true in the case of integers.

白昼 2025-01-05 09:35:39

非常相似的问题:
ColdFusion 认为“虚假”的所有值是什么” 和“truthy”?

关于如何在 ColdFusion 中评估变量的真实性的大量博客文章:
ColdFusion 认为“虚假”的所有值是什么”和“真实”?

Very similar question:
What are all the values that ColdFusion considers "falsy" and "truthy"?

Extensive blog post about how variables are evaluated for truthiness in ColdFusion:
What are all the values that ColdFusion considers "falsy" and "truthy"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文