- Int: signed 64bit integer
- String: string
- Float: 64bit floating point
- 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
- Undefined: undefined
src\dst | Int | String | Float | Bool | Char | Bytes | Array | Map | Time | Error | Undefined |
---|---|---|---|---|---|---|---|---|---|---|---|
Int | - | strconv | float64(v) | !IsFalsy() | rune(v) | X | X | X | time.Unix() | 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 |
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 |
Undefined | 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()
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) - Undefined:
true
(Undefined is always falsy)
string(x)
: tries to convertx
into string; returnsundefined
if failedint(x)
: tries to convertx
into int; returnsundefined
if failedbool(x)
: tries to convertx
into bool; returnsundefined
if failedfloat(x)
: tries to convertx
into float; returnsundefined
if failedchar(x)
: tries to convertx
into char; returnsundefined
if failedbytes(x)
: tries to convertx
into bytes; returnsundefined
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; returnsundefined
if failed- See Builtins for the full list of builtin functions.
is_string(x)
: returnstrue
ifx
is string;false
otherwiseis_int(x)
: returnstrue
ifx
is int;false
otherwiseis_bool(x)
: returnstrue
ifx
is bool;false
otherwiseis_float(x)
: returnstrue
ifx
is float;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_undefined(x)
: returnstrue
ifx
is undefined;false
otherwise- See Builtins for the full list of builtin functions.