ext

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 0 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Choose

func Choose[T any](expr bool, ift T, iff T) T

Choose implements the missing ternary (?:) operator. When the provided expression evalutes to true, the first result parameter is returned; otherwise the second.

Choose(len(s) == 1, "true", "false")

func Coalesce added in v1.29.0

func Coalesce[T comparable](v ...T) T

Coalesce returns the first non-zero value in the provided arguments. If no argument is non-zero, the zero value is returned.

Coalesce("", "", "hello", "") // "hello"
Coalesce(nil, ptr, nil) // ptr

Types

This section is empty.

Jump to

Keyboard shortcuts

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