Tender Runtime Types
- Int: signed 64bit integer
- BigInt: arbitrary-precision integer (big integer)
- String: string
- Float: 64bit floating point
- BigFloat: arbitrary-precision floating point (big float)
- Bool: boolean
- Char: character (
rune
in Go) - Bytes: byte array (
[]byte
in Go) - Array: objects array (
[]Object
in Go) - ImmutableArray: immutable object array (
[]Object
in Go) - Map: objects map with string keys (
map[string]Object
in Go) - ImmutableMap: immutable object map with string keys (
map[string]Object
in Go) - Time: time (
time.Time
in Go) - Error: an error with underlying Object value of any type
- Null: null
Type Conversion/Coercion Table
src\dst | Int | String | Float | Bool | Char | Bytes | Array | Map | Time | Error | Null |
---|---|---|---|---|---|---|---|---|---|---|---|
Int | - | strconv | float64(v) | !IsFalsy() | rune(v) | X | X | X | time.Unix() | X | X |
BigInt | - | - | !IsFalsy() | - | X | X | X | - | X | X | |
String | strconv | - | strconv | !IsFalsy() | X | []byte(s) | X | X | X | X | X |
Float | int64(f) | strconv | - | !IsFalsy() | X | X | X | X | X | X | X |
BigFloat | - | - | !IsFalsy() | - | X | X | X | - | X | X | |
Bool | 1 / 0 | "true" / "false" | X | - | X | X | X | X | X | X | X |
Char | int64(c) | string(c) | X | !IsFalsy() | - | X | X | X | X | X | X |
Bytes | X | string(y) | X | !IsFalsy() | X | - | X | X | X | X | X |
Array | X | "[...]" | X | !IsFalsy() | X | X | - | X | X | X | X |
Map | X | "{...}" | X | !IsFalsy() | X | X | X | - | X | X | X |
Time | X | String() | X | !IsFalsy() | X | X | X | X | - | X | X |
Error | X | "error: ..." | X | false | X | X | X | X | X | - | X |
Null | X | X | X | false | X | X | X | X | X | X | - |
X: No conversion; Typed value functions for Variable
will
return zero values.
strconv: converted using Go's conversion functions from strconv
package.
IsFalsy(): use Object.IsFalsy() function_
_ String(): use Object.String()
function
* time.Unix(): use time.Unix(v, 0)
to convert to Time
Object.IsFalsy()
Object.IsFalsy()
interface method is used to determine if a given value
should evaluate to false
(e.g. for condition expression of if
statement).
- Int:
n == 0
- String:
len(s) == 0
- Float:
isNaN(f)
- Bool:
!b
- Char:
c == 0
- Bytes:
len(bytes) == 0
- Array:
len(arr) == 0
- Map:
len(map) == 0
- Time:
Time.IsZero()
- Error:
true
(Error is always falsy) - Null:
true
(Null is always falsy)
Type Conversion Builtin Functions
string(x)
: tries to convertx
into string; returnsnull
if failedint(x)
: tries to convertx
into int; returnsnull
if failedbool(x)
: tries to convertx
into bool; returnsnull
if failedfloat(x)
: tries to convertx
into float; returnsnull
if failedchar(x)
: tries to convertx
into char; returnsnull
if failedbytes(x)
: tries to convertx
into bytes; returnsnull
if failedbytes(N)
: as a special case this will create a Bytes variable with the given sizeN
(only ifN
is int)time(x)
: tries to convertx
into time; returnsnull
if failed
Type Checking Builtin Functions
is_string(x)
: returnstrue
ifx
is string;false
otherwiseis_int(x)
: returnstrue
ifx
is int;false
otherwiseis_bigint(x)
: returnstrue
ifx
is bigint;false
otherwiseis_bool(x)
: returnstrue
ifx
is bool;false
otherwiseis_float(x)
: returnstrue
ifx
is float;false
otherwiseis_bigfloat(x)
: returnstrue
ifx
is bigfloat;false
otherwiseis_char(x)
: returnstrue
ifx
is char;false
otherwiseis_bytes(x)
: returnstrue
ifx
is bytes;false
otherwiseis_array(x)
: returntrue
ifx
is array;false
otherwiseis_immutable_array(x)
: returntrue
ifx
is immutable array;false
otherwiseis_map(x)
: returntrue
ifx
is map;false
otherwiseis_immutable_map(x)
: returntrue
ifx
is immutable map;false
otherwiseis_time(x)
: returntrue
ifx
is time;false
otherwiseis_error(x)
: returnstrue
ifx
is error;false
otherwiseis_null(x)
: returnstrue
ifx
is null;false
otherwise