ensure multimethod
Methods
- ensure(x:Any, pat:Any, how:Any)experimental Source: stdlib.ngs:1505
EXPERIMENTAL! Do not use! Ensures that value matches pattern. If the value matches, it is returned as is. If not, Value(how, x) is used instead. In this case, there is assert() to see that the new value is matching pat. Example
ensure(param, Str, encode_json)
- ensure(x:Any, t:Type)experimental Source: stdlib.ngs:1828
EXPERIMENTAL! Do not use! Makes sure returned value is of type t. If x is already of type t, returns x. Otherwise, returns object of type t with single item x. Parameters
t a subtype of Eachable1 Returns
Object of type t
- ensure(x:Arr, t:Type) Source: stdlib.ngs:1936
Undocumented Parameters
t subtype of ArrLike Returns
of type t
- ensure(n:Int, r:NumRange) Source: stdlib.ngs:2715
Checks that x is in the range. Example
ensure(3, 3..10) # 3
- ensure(e:Eachable1, p:Present) Source: stdlib.ngs:4464
Ensure a value is present. Does e.push(p.val) conditionally. Example
[1,2].ensure(Present(3)) == [1,2,3] [1,2].ensure(Present(2)) == [1,2]