Documentation
¶
Index ¶
- type Nullable
- func (receiver Nullable[T]) Filter(fn func(T) bool) Nullable[T]
- func (receiver Nullable[T]) Get() (T, bool)
- func (receiver Nullable[T]) GetElse(alternative T) T
- func (receiver Nullable[T]) GoString() string
- func (receiver Nullable[T]) IsNothing() bool
- func (receiver Nullable[T]) IsNull() bool
- func (receiver Nullable[T]) MarshalJSON() ([]byte, error)
- func (receiver Nullable[T]) Optional() opt.Optional[T]
- func (receiver *Nullable[T]) UnmarshalJSON(data []byte) error
- func (receiver Nullable[T]) WhenNothing(fn func())
- func (receiver Nullable[T]) WhenNull(fn func())
- func (receiver Nullable[T]) WhenSomething(fn func(T))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Nullable ¶
type Nullable[T any] struct { // contains filtered or unexported fields }
func (Nullable[T]) Get ¶
Get returns the value inside of the nullable-optional-type if it is holding something.
Example usage:
var nl nul.Nullable[string]
// ...
value, found := nl.Get()
if found {
fmt.Println("VALUE:", value)
} else {
fmt.Println("nothing")
}
func (Nullable[T]) GetElse ¶
func (receiver Nullable[T]) GetElse(alternative T) T
GetElse returns the value inside of the nullable-optional-type if it is holding something. Else it returns the alternstive value passed as a parameter. Example usage:
var nl nul.Nullable[string]
// ...
value := nl.GetElse(alternative)
fmt.Println("VALUE:", value)
func (Nullable[T]) MarshalJSON ¶
MarshalJSON makes it so json.Marshaler is implemented.
func (*Nullable[T]) UnmarshalJSON ¶
UnmarshalJSON makes it so json.Unmarshaler is implemented.
func (Nullable[T]) WhenNothing ¶
func (receiver Nullable[T]) WhenNothing(fn func())
func (Nullable[T]) WhenSomething ¶
func (receiver Nullable[T]) WhenSomething(fn func(T))
Click to show internal directories.
Click to hide internal directories.