operator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indirect

func Indirect[P *E, E any](p P) (E, bool)

Indirect returns the value pointed to by p.

func IndirectOrZero

func IndirectOrZero[P *E, E any](p P) E

IndirectOrZero returns the value pointed to by p or zero value of E.

func Pointer

func Pointer[E any](v E) *E

Pointer stores v in a new E value and returns a pointer to it.

func SwitchCases

func SwitchCases[K comparable, V any](key K, keys []K, values []V) (V, bool)

func Ternary

func Ternary[T any](condition bool, exprIfTrue, exprIfFalse T) T

Ternary is akin to a ternary operator in Go, which based on the boolean `condition`, returns either `exprIfTrue` or `exprIfFalse`. It utilizes generics `T`, making it applicable for expressions of any type.

func TernaryFunc

func TernaryFunc[T any](condition bool, exprIfTrue, exprIfFalse func() T) T

TernaryFunc is akin to a ternary operator in Go, which conditionally executes either `exprIfTrue` or `exprIfFalse` based on the value of `condition`, and returns the result of the executed function. It leverages Go's generics feature, making it applicable for any type `T`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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