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

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

Methods

.(hl:HashLike, k:Any) Source: stdlib.ngs:786
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:791
Set value.

Automatically called by NGS for syntax

your_hashlike.literal_key = v

Returns

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

Automatically called by NGS for syntax

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

Automatically called by NGS for syntax

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

Returns

Bool
dflt(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:1093
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:805
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:828
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

HashLike

Example

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

Returns

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

Returns

Any
Hash(hl:HashLike) Source: stdlib.ngs:846
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:768
Check whether k is in the HashLike

Returns

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

Parameters

hIf provided, used as initial value.

Example

HashLike(%{a aha b bee}) # <HashLike a=aha b=bee>
keys(hl:HashLike) Source: stdlib.ngs:811
Get keys

Returns

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

Returns

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

Returns

Arr