Syntax
Value.As(value as any, type as type) as any
About
如果值与指定类型兼容,则返回该值。 这相当于 M 中的“as”运算符,但例外是它可以接受标识符类型引用,如 Number.Type。
示例 1
将数字强制转换为数字。
用法
Value.As(123, Number.Type)
输出
123
示例 2
尝试将文本值强制转换为数字。
用法
Value.As("abc", type number)
输出
[Expression.Error] We cannot convert the value "abc" to type Number.