each multimethod

Methods

each(mm:MultiMethod, cb:Fun) Source: stdlib.ngs:141
Call cb for each method of the MultiMethod

Example

echo.each(F(method) echo("${method.params().name.join(", ")}"))
each(al:ArrLike, cb:Fun) Source: stdlib.ngs:727
Call cb for each element in the underlying array.
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"))
each(r:NumRange, cb:Fun) Source: stdlib.ngs:1344
Iterates over the elements of r, passing each in turn to cb.

Parameters

cbFunction to be called with values from r

Returns

r

Example

s=0
(1...10).each(F(i) { global s; s+=i })
echo(s)  # Outputs: 55
each(arr:Arr, cb:Fun) Source: stdlib.ngs:1746
Iterates over the elements of arr, passing each in turn to cb along with args: cb(ITEM)

Parameters

cbFunction to be called with values from arr

Returns

arr

Example

s=0
[1,2,3].each(F(i) { global s; s+=i })
echo(s)  # Outputs: 6
each(arr:Arr, n:Int, cb:Fun) Source: stdlib.ngs:1807
Process each N elements of an Array at a time. Throws InvalidArgument if number of items in arr is not divisible by n. cb is called as cb(eltI, ..., eltJ) where I is multiple of n and J is I+n-1

Parameters

arrItems to iterate in chunks of n
nNumber of items in chunk
cbFunction to be called with values from arr

Returns

arr

Example

[1,2,3,4].each(2, F(a, b) echo("$a - $b"))  # Outputs: "1 - 2" and on the next line "3 - 4"
each(h:Hash, cb:Fun) Source: stdlib.ngs:2428
Iterate a Hash.

Parameters

hHash to iterate
cbFunction to call with successive keys and values

Returns

h

Example

{"a": 1, "b": 2}.each(F(k, v) echo("$k=$v"))  # Outputs: "a=1" and on the next line "b=2"
each(fb:FullBox, cb:Fun) Source: stdlib.ngs:2862
Call cb with the value of the FullBox

Returns

fb

Example

Box(10).each(echo)  # Output: 10
each(eb:EmptyBox, cb:Fun) Source: stdlib.ngs:2867
Do nothing

Returns

eb

Example

Box(null).each(echo)  # No output
each(s:Success, fun:Fun) Source: stdlib.ngs:3063
Run fun with wrapped value.
each(f:Failure, fun:Fun) Source: stdlib.ngs:3079
No-op, returns f

Returns

f
each(n:Int, cb:Fun) Source: stdlib.ngs:3300
Iterate from zero up to but not including n

Parameters

cbFunction to call with current number

Returns

n

Example

10.each(echo)  # Outputs numbers from 0 to 9 inclusive, one on each line
each(s:Str, cb:Fun) Source: stdlib.ngs:3397
Iterates over all string characters (currently bytes).

Parameters

cbFunction to be called with each character from s

Returns

s

Example

"abc".each(echo)
# Output:
# a
# b
# c
each(rd:ResDef, cb:Fun) Source: autoload/Res.ngs:80
Call cb with properties of each found resource

Returns

rd

Example

AWS::Instance().each(F(i) echo(i.InstanceId))
each(i:Iter, cb:Fun) Source: autoload/Iter.ngs:98
Calls cb with each element from i

Returns

i

Example

Iter(10).each(echo)  # Prints 0 to 9
each(s:Set, cb:Fun) Source: autoload/Set.ngs:30
Call cb for each value in the set

Returns

s
each(t:Table, cb:Fun) Source: autoload/Table.ngs:98
Please do not use. This method might change. Call cb with each table row.