dflt multimethod

Methods

dflt(i:NormalTypeInstance, k:Any, v:Any) Source: stdlib.ngs:792
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(s:Success, x:Any) Source: stdlib.ngs:912
Undocumented

Returns

s
dflt(f:Failure, x:Any) Source: stdlib.ngs:915
Undocumented

Returns

Value(x,f)
dflt(e:Eachable1, k:Any, v:Any) Source: stdlib.ngs:2490
Set a field on all elements if it's not already set

Parameters

eEachable1

Returns

e

Example

my_items.dflt("source", "(unknown)")
dflt(hl:HashLike, k:Any, v:Any) Source: stdlib.ngs:2499
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:4142
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:4355
Do nothing

Returns

fb

Example

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:4366
Wrap x in a Box

Returns

FullBox with the value x

Example

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