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

Function ExampleDo

do_example_test.go:8–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6)
7
8func ExampleDo() {
9 a := Ok("Hello, World!")
10 b := Some("42")
11
12 result := Do(func() []string {
13 return []string{
14 a.MustGet(),
15 b.MustGet(),
16 }
17 })
18
19 fmt.Println(result.IsError())
20 fmt.Println(result.MustGet())
21 // Output:
22 // false
23 // [Hello, World! 42]
24}
25
26func ExampleDo_panic() {
27 a := Ok("Hello, World!")

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
SomeFunction · 0.85
DoFunction · 0.85
IsErrorMethod · 0.80
MustGetMethod · 0.45

Tested by

no test coverage detected