次の方法で共有


Value.As

構文

Value.As(value as any, type as type) as any

バージョン情報

指定した型と互換性がある場合は、値を返します。 これは 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.