option

package
v0.1.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrElse

func GetOrElse[A any](a Option[A], def A) A

Types

type None

type None[A any] struct{}

type Option

type Option[A any] interface{}

Represents optional values. Instances of Option are either an instance of Some or a type-safe empty structure None. The most idiomatic way to use an Option instance is to treat it as a collection or monad and use Map or FlatMap. If None is returned from any operation in the chain, the entire expression results in None[T]. This allows for sophisticated chaining of Option values without having to check for the existence of a value.

func FlatMap

func FlatMap[A, B any](a Option[A], f func(A) Option[B]) Option[B]

func Map

func Map[A, B any](a Option[A], f func(A) B) Option[B]

type Some

type Some[A any] struct {
	Value A
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL