Documentation
¶
Overview ¶
Package nullable provides a generic value with an explicit null state. It does not implement JSON, BSON, or SQL encoding interfaces.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Null ¶
type Null[T any] struct { // contains filtered or unexported fields }
Null is a generic type that represents a nullable value. There are 2 possible states:
Null: > value: zero value of T > valid: false
Not Null: > value: value of T > valid: true
func Some ¶
Some returns a Null[T] with valid set to true.
Example ¶
package main
import (
"fmt"
"github.com/cohesian-tools/typy/opt/nullable"
)
func main() {
value := nullable.Some(0)
missing := nullable.None[int]()
fmt.Println(value.IsNull(), value.Unwrap())
fmt.Println(missing.IsNull())
}
Output: false 0 true