each multimethod
Methods
- each(mm:MultiMethod, cb:Fun) Source: stdlib.ngs:137
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:666
Call cb for each element in the underlying array.
- each(hl:HashLike, cb:Fun) Source: stdlib.ngs:721
Iterate over keys and values. Returns
hlExample
my_hashlike.each(F(k, v) echo("$k=$v"))
- each(r:NumRange, cb:Fun) Source: stdlib.ngs:1215
Iterates over the elements of r, passing each in turn to cb. Parameters
cb Function to be called with values from r Returns
rExample
s=0 (1...10).each(F(i) { global s; s+=i }) echo(s) # Outputs: 55
- each(arr:Arr, cb:Fun) Source: stdlib.ngs:1608
Iterates over the elements of arr, passing each in turn to cb along with args: cb(ITEM) Parameters
cb Function to be called with values from arr Returns
arrExample
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:1669
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
arr Items to iterate in chunks of n n Number of items in chunk cb Function to be called with values from arr Returns
arrExample
[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:2289
Iterate a Hash. Parameters
h Hash to iterate cb Function to call with successive keys and values Returns
hExample
{"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:2723
Call cb with the value of the FullBox Returns
fbExample
Box(10).each(echo) # Output: 10
- each(eb:EmptyBox, cb:Fun) Source: stdlib.ngs:2728
Do nothing Returns
ebExample
Box(null).each(echo) # No output
- each(s:Success, fun:Fun) Source: stdlib.ngs:2921
Run fun with wrapped value.
- each(f:Failure, fun:Fun) Source: stdlib.ngs:2937
No-op, returns f Returns
f
- each(n:Int, cb:Fun) Source: stdlib.ngs:3157
Iterate from zero up to but not including n Parameters
cb Function to call with current number Returns
nExample
10.each(echo) # Outputs numbers from 0 to 9 inclusive, one on each line
- each(s:Str, cb:Fun) Source: stdlib.ngs:3252
Iterates over all string characters (currently bytes). Parameters
cb Function to be called with each character from s Returns
sExample
"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
rdExample
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
iExample
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.