Skip to main content

Value.As

Pateikia reikšmę, jei ji yra suderinama su nurodytu tipu.

Syntax

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

Remarks

Pateikia vertę, jei ji suderinama su nurodytu tipu. Tai atitinka operatorių „kaip“ M, išskyrus tai, kad jis gali priimti identifikatoriaus tipo nuorodas, pvz., Number.Type.

Examples

Example #1

Keisti skaičių į skaičių.

Value.As(123, Number.Type)

Result:

123

Example #2

Bandoma pakeisti tekstinę reikšmę į skaičių.

Value.As("abc", type number)

Result:

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

Category

Values.Types