dflt multimethod
Methods
- dflt(i:NormalTypeInstance, k:Any, v:Any) Source: stdlib.ngs:946
Set object field if it's not already set Returns
Field value, the already-existed or new.Example
my_something.dflt(k, []).push(elt)
- dflt(e:Eachable1, k:Any, v:Any) Source: stdlib.ngs:960
Set a field on all elements if it's not already set Parameters
e Eachable1 with elements of type NormalTypeInstance or Hash Returns
eExample
my_items.dflt("source", "(unknown)")
- dflt(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:984
Set a key if it's not already set Returns
Key value, the already-existed or new.Example
mysomething.dflt(k, []).push(elt)
- dflt(h:Hash, k:Any, v:Any) Source: stdlib.ngs:2617
Set a key in a Hash if it's not already set Returns
Hash value, the already-existed or new.Example
my_hash.dflt(k, []).push(elt)
- dflt(fb:FullBox, x:Any) Source: stdlib.ngs:2833
Do nothing Returns
fbExample
my_array = [10, 20] # dflt on FullBox has no effect my_array.Box(1).dflt(100).map(X*2).each(echo) # HERE # output: 40 # dflt on EmptyBox creates FullBox with the given value my_array.Box(5).dflt(100).map(X*2).each(echo) # output: 200
- dflt(eb:EmptyBox, x:Any) Source: stdlib.ngs:2844
Wrap x in a Box Returns
FullBox with the value xExample
my_array = [10, 20] # dflt on FullBox has no effect my_array.Box(1).dflt(100).map(X*2).each(echo) # output: 40 # dflt on EmptyBox creates FullBox with the given value my_array.Box(5).dflt(100).map(X*2).each(echo) # HERE # output: 200