# Eachable2 type

## Direct parent types

- Eachable
Parent type of all types that have each() method Direct subtypes: 2

## Direct children types

- Hash
Hash type. Maps unique keys to their values. Key-Value pairs are stored and iterated in insertion order. Currently Hash type has several limitations: Hash keys are hashed using internal hash() function which can not be overwritten. The internal hash() multimethod exposed to NGS code but adding methods to it or setting "hash" to some other function will not affect operation of Hashes. Hash values are compared using internal is_equal() function which can not be overwritten. Both hash() and is_equal() currently handle only Int, Str and arbitrary objects. Comparison of arbitrary objects is done by comparing their addresses in memory.

- HashLike
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 subtypes: 2

## Methods

- count(e:Eachable2, predicate:Any) Source: stdlib.ngs:2603
Count number of key-value pairs in Hash that satisfy the predicate. #### Parameters

e Something to check, typically a Hash predicate Test function to be called with one key and one value at a time #### Returns

Int#### Example

{'a': 1, 'b': 2, 'c': 11}.count(F(k, v) v>10) # 1

- filterk(h:Eachable2, predicate:Any) Source: stdlib.ngs:2573
Filter hash by keys, keeping matched #### Example

{"a": 1, "b": 2, "ccc": 3}.filterk(/^.$/) # {a=1, b=2} {"aa": 1, "ab": 2, "ba": 3}.filterk(/^a/) # {aa=1, ab=2} {"aa": 1, "ab": 2, 10: 3}.filterk(Int) # {10=3} {10: "a", 20: "b", 30: "c"}.filterk(X > 10) # {20=b, 30=c}

- filterv(h:Eachable2, predicate:Any) Source: stdlib.ngs:2586
Filter hash by values #### Example

{"a1": 1, "a2": 2, "b1": 10}.filterv(X>5) # {"b1": 10}

- rejectk(h:Eachable2, predicate:Any) Source: stdlib.ngs:2579
Filter hash by keys, removing matched. See filterk(). #### Example

{"a1": 1, "a2": 2, "b1": 10}.rejectk(/^b/) # {"a1": 1, "a2": 2}

- rejectv(h:Eachable2, predicate:Any) Source: stdlib.ngs:2592
Filter hash by values

- without(e:Eachable2, without_k:Any) Source: stdlib.ngs:2686
Filter out specific key #### Parameters

e Source without_k The key to filter out #### Example

{'a': 1, 'b': 2, 'c': 3}.without('a') # {'b': 2, 'c': 3}

- without(e:Eachable2, without_k:Any, without_v:Any) Source: stdlib.ngs:2696
Filter out specific key-value pair #### Parameters

e Source without_k The key to filter out without_v The value to filter out #### Example

{'a': 1, 'b': 2, 'c': 3}.without('a', 1).without('b', 22) # {'b': 2, 'c': 3}