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

Function ExampleOption_Match_some

option_example_test.go:211–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209}
210
211func ExampleOption_Match_some() {
212 some := Some(42)
213 result := some.Match(
214 func(i int) (int, bool) {
215 return 0, false
216 },
217 func() (int, bool) {
218 return 2, true
219 },
220 )
221
222 fmt.Println(result.IsPresent(), result.OrEmpty())
223 // Output: false 0
224}
225
226func ExampleOption_Match_none() {
227 none := None[int]()

Callers

nothing calls this directly

Calls 4

SomeFunction · 0.85
IsPresentMethod · 0.80
MatchMethod · 0.45
OrEmptyMethod · 0.45

Tested by

no test coverage detected