Success type

Successful computation

Direct parent types

Result
Result of a computation
Direct subtypes: 2

Methods

Bool(s:Success) Source: stdlib.ngs:958
Convert Success to Bool (true)

Returns

true
Box(s:Success) Source: stdlib.ngs:7456
Convert Success to FullBox

Returns

FullBox

Example

Box("abcd" ~ /^(..)/).map({"First two letters: ${A[1]}"}).get("(too short)")  # First two letters: ab
dflt(s:Success, x:Any) Source: stdlib.ngs:912
Undocumented

Returns

s
each(s:Success, fun:Fun) Source: stdlib.ngs:922
Run fun with wrapped value.
filter(s:Success, pattern:Any=method) Source: stdlib.ngs:943
Check whether wrapped value matches the pattern.

Returns

s or Failure

Example

Success(10).filter(X>5)   # <Success val=10>
Success(10).filter(X>15)  # <Failure val=<ResultFail ...>>
get(s:Success) Source: stdlib.ngs:894
Gets wrapped value

Returns

Any

Example

{ 1 / 10 }.Result().get()  # 0
get(s:Success, dflt:Any) Source: stdlib.ngs:905
Gets wrapped value

Returns

Any

Example

{ 1 / 10 }.Result().get(100)  # 0
init(s:Success, v:Any=null) Source: stdlib.ngs:886
Initialize Success with the given value.
JsonData(s:Success) Source: stdlib.ngs:973
Convert Success into JSON compatible data structure - the value of the computation
map(s:Success, fun:Fun) Source: stdlib.ngs:928
Run fun with wrapped value. If exception is thrown, Failure is returned; otherwise Success with new value is returned.

Returns

Result