MCPcopy
hub / github.com/samber/mo / ExampleResult_FlatMap_ok

Function ExampleResult_FlatMap_ok

result_example_test.go:342–352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

340}
341
342func ExampleResult_FlatMap_ok() {
343 ok := Ok(42)
344 result := ok.FlatMap(
345 func(i int) Result[int] {
346 return Ok(1234)
347 },
348 )
349
350 fmt.Println(result.IsError(), result.OrEmpty(), result.Error())
351 // Output: false 1234 <nil>
352}
353
354func ExampleResult_FlatMap_err() {
355 ko := Err[int](err)

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
IsErrorMethod · 0.80
ErrorMethod · 0.80
FlatMapMethod · 0.65
OrEmptyMethod · 0.45

Tested by

no test coverage detected