rune
in Go)[]byte
in Go)[]Object
in Go)[]Object
in Go)map[string]Object
in Go)map[string]Object
in Go)time.Time
in Go)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).
n == 0
len(s) == 0
isNaN(f)
!b
c == 0
len(bytes) == 0
len(arr) == 0
len(map) == 0
Time.IsZero()
true
(Error is always falsy)true
(Undefined is always falsy)string(x)
: tries to convert x
into string; returns undefined
if failedint(x)
: tries to convert x
into int; returns undefined
if failedbool(x)
: tries to convert x
into bool; returns undefined
if failedfloat(x)
: tries to convert x
into float; returns undefined
if failedchar(x)
: tries to convert x
into char; returns undefined
if failedbytes(x)
: tries to convert x
into bytes; returns undefined
if failed
bytes(N)
: as a special case this will create a Bytes variable with the
given size N
(only if N
is int)time(x)
: tries to convert x
into time; returns undefined
if failedis_string(x)
: returns true
if x
is string; false
otherwiseis_int(x)
: returns true
if x
is int; false
otherwiseis_bool(x)
: returns true
if x
is bool; false
otherwiseis_float(x)
: returns true
if x
is float; false
otherwiseis_char(x)
: returns true
if x
is char; false
otherwiseis_bytes(x)
: returns true
if x
is bytes; false
otherwiseis_array(x)
: return true
if x
is array; false
otherwiseis_immutable_array(x)
: return true
if x
is immutable array; false
otherwiseis_map(x)
: return true
if x
is map; false
otherwiseis_immutable_map(x)
: return true
if x
is immutable map; false
otherwiseis_time(x)
: return true
if x
is time; false
otherwiseis_error(x)
: returns true
if x
is error; false
otherwiseis_undefined(x)
: returns true
if x
is undefined; false
otherwise