Value.As
Sintassi
Value.As(value as any, type as type) as any
Informazioni su
Restituisce il valore se è compatibile con il tipo specificato. È equivalente all'operatore "as" in M, con l'eccezione che può accettare riferimenti di tipo identificatore, ad esempio Number.Type.
Esempio 1
Eseguire il cast di un numero a un numero.
Utilizzo
Value.As(123, Number.Type)
Output
123
Esempio 2
Tentativo di eseguire il cast di un valore di testo a un numero.
Utilizzo
Value.As("abc", type number)
Output
[Expression.Error] We cannot convert the value "abc" to type Number.