Stats type

A group of named counters

Example

s = Stats().push('a').push('a').push('b')
s["a"]  # 2
s["b"]  # 1

a = ["x", "y", "y"]
s = Stats(a)
s["x"]  # 1
s["y"]  # 2

Direct parent types

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

init(s:Stats, a:Arr) Source: stdlib.ngs:3776
Makes Stats, with each element in the array counted as if push()ed

Example

Stats(['a', 'a', 'b']).Hash()  # {'a': 2, 'b': 1}
push(s:Stats, k:Any) Source: stdlib.ngs:3784
Increment the named counter

Parameters

kthe name of the counter to increment

Example

Stats().push("a").push("a").push("b")["a"]  # 2