HashLike type

Base type for user-defined hash-like types. This is a workaround: it's not possible currently no inherit from the built-in Hash type.

Direct parent types

Eachable2
Eachable which each() calls the callback with two arguments
Direct subtypes: 2

Direct children types

DecodeHints
Undocumented
Hook
Hook is a simple pub-sub
Stats
A group of named counters

Methods

.(hl:HashLike, k:Any) Source: stdlib.ngs:1639
Get value by key. Throws KeyNotFound.

Automatically called by NGS for syntax

your_hashlike.literal_key

Returns

Any
.=(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:1644
Set value.

Automatically called by NGS for syntax

your_hashlike.literal_key = v

Returns

v
[](hl:HashLike, k:Any) Source: stdlib.ngs:1630
Get value by key. Throws KeyNotFound.

Automatically called by NGS for syntax

your_hashlike[k]
[]=(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:1634
Set value.

Automatically called by NGS for syntax

your_hashlike[k] = v
Bool(hl:HashLike) Source: stdlib.ngs:1669
Check whether hl has any elements.

Returns

Bool
del(hl:HashLike, k:Any) Source: stdlib.ngs:1688
Remove k from hl

Returns

hl
dflt(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:2035
Set a key if it's not already set

Returns

Key value, the already-existed or new.

Example

mysomething.dflt(k, []).push(elt)
each(hl:HashLike, cb:Fun) Source: stdlib.ngs:1657
Iterate over keys and values.

Returns

hl

Example

my_hashlike.each(F(k, v) echo("$k=$v"))
filter(hl:HashLike, predicate:Fun) Source: stdlib.ngs:1678
Filter hash. Build new HashLike with kev-value pairs selected by predicate.

Parameters

predicateTest function to be called with one key and one value at a time.

Returns

value of the same type as hl

Example

my_hashlike.filter(F(k, v) k == 'a')
get(hl:HashLike, k:Any, dflt:Any) Source: stdlib.ngs:1648
Get value by key or dflt if it does not exist

Returns

Any
get(hl:HashLike, k:Any) Source: stdlib.ngs:1652
Get value by key or null if it does not exist

Returns

Any
Hash(hl:HashLike) Source: stdlib.ngs:1701
Get the underlying Hash with all the keys/values of the HashLike. Note: the returned value is not a copy.

Returns

Hash
in(k:Any, hl:HashLike) Source: stdlib.ngs:1621
Check whether k is in the HashLike

Returns

Bool
init(hl:HashLike, h:Hash=null) Source: stdlib.ngs:1696
Create a HashLike.

Parameters

hIf provided, used as initial value.

Example

HashLike(%{a aha b bee}) # <HashLike a=aha b=bee>
JsonData(hl:HashLike) Source: stdlib.ngs:1704
Convert HashLike into JSON compatible data structure - object
keys(hl:HashLike) Source: stdlib.ngs:1661
Get keys

Returns

Arr
len(hl:HashLike) Source: stdlib.ngs:1625
Get number of key-value pairs in a HashLike

Returns

Int
map_idx_key_val(hl:HashLike, mapper:Fun) Source: stdlib.ngs:1671
Undocumented
values(hl:HashLike) Source: stdlib.ngs:1665
Get values

Returns

Arr