ToNumber

ToNumber( value )
ToNumber( value )
ToNumber( value )
ToNumber( value )
ToNumber( value )
ToNumber( value )
Not available in this language yet.
Not available in this language yet.

Description

The ToNumber function converts a value to a numeric literal, if possible.

Attempting to convert a value to a number which has no numeric representation results in an "invalid argument" error.

Parameters

Argument Type Definition and Requirements

value

Any

The value to attempt to convert to a number type.

Returns

A number type of value.

Examples

The query below executes an array of independent ToNumber operations and returns the results in an array. The result array position matches the execution array position. The first operation converts a floating point literal to a number. The second operation takes an integer literal and converts it to a number. The last operation converts a string to a number.

System.out.println(
        client.query(Arr(
                ToNumber(Value(1234.5678)),
                ToNumber(Value(1234)),
                ToNumber(Value("123"))
        )).get());
result, _ := client.Query(f.Arr{
    f.ToNumber(1234.5678),
    f.ToNumber(1234),
    f.ToNumber("123")})
fmt.Println(result)
client.query([
  q.ToNumber(1234.5678),
  q.ToNumber(1234),
  q.ToNumber('123'),
]).then((ret) => console.log(ret))
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
[1234.5678, 1234, 123]
[1234.5678 1234 123]
[ 1234.5678, 1234, 123 ]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!