ext

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 0 Imported by: 5

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

type Zeroer added in v1.36.0

type Zeroer interface {
	IsZero() bool
}

Zeroer is implemented by types that can represent a non-literal zero value

Jump to

Keyboard shortcuts

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