使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
cast.as_bool
cast.as_bool(string_or_int)
说明
函数将 int 或字符串值转换为布尔值。如果函数调用中使用的值无法转换,则会返回 FALSE。仅当值为整数 1 和不区分大小写的字符串“true”时,返回 TRUE。
形参数据类型
INT|STRING
返回类型
BOOL
代码示例
示例 1
此示例展示了如何转换非布尔值字符串
cast.as_bool("123") = false
示例 2
Truthy 整数 (1)
cast.as_bool(1) = true
示例 3
Truthy 字符串
cast.as_bool("true") = true
示例 4
大写真实值字符串
cast.as_bool("TRUE") = true
示例 5
负整数
cast.as_bool(0-1) = false
示例 6
假整数 (0)
cast.as_bool(0) = false
示例 7
空字符串
cast.as_bool("") = false
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[],[],null,[]]