Passa al contenuto principale

Value.As

Restituisce il valore se è compatibile con il tipo specificato.

Syntax

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

Remarks

Restituisce il valore se è compatibile con il tipo specificato. Equivale all'operatore "as" in M, con l'eccezione che può accettare riferimenti al tipo di identificatore, ad esempio Number.Type.

Examples

Example #1

Esegue il cast di un numero a un numero.

Value.As(123, Number.Type)

Result:

123

Example #2

Tentativo di eseguire il cast di un valore di testo a un numero.

Value.As("abc", type number)

Result:

[Expression.Error] We cannot convert the value "abc" to type Number.

Category

Values.Types