Stats type
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"] # 2Direct 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: 4
Methods
- collector(s:Stats, body:Fun) Source: stdlib.ngs:5203
Undocumented
- init(s:Stats, e:Eachable1) Source: stdlib.ngs:5181
Makes Stats, with each element in the array counted as if push()ed Example
Stats(['a', 'a', 'b']).Hash() # {'a': 2, 'b': 1} Stats("AABC").Hash() # {A=2, B=1, C=1}
- JsonData(s:Stats) Source: stdlib.ngs:5200
Convert Stats into JSON compatible data structure - object
- push(s:Stats, k:Any) Source: stdlib.ngs:5189
Increment the named counter Parameters
k the name of the counter to increment Example
Stats().push("a").push("a").push("b")["a"] # 2