Success type

Successful computation

Direct parent types

Result
Result of a computation
Direct subtypes: 2

Direct children types

MatchSuccess
Successful match result
Direct subtypes: 1

Methods

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

Returns

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

Returns

FullBox

Example

Box("abcd" ~ /^(..)/).map({"First two letters: ${A[1]}"}).get("(too short)")  # First two letters: ab
each(s:Success, fun:Fun) Source: stdlib.ngs:3969
Run fun with wrapped value.
filter(s:Success, pattern:Any=method) Source: stdlib.ngs:3990
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:3950
Gets wrapped value

Returns

Any

Example

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

Returns

Any

Example

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

Returns

Result