functions

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Id

func Id[T any](v T) T

Identity function - returns the value passed.

func IfElse

func IfElse[T any](cond bool, v T, alt T) T

Ternary logic function. If `cond` is true, `v` is returned. Otherwise `alt` is returned.

func IfElseF

func IfElseF[T any](cond bool, f func() T, alt func() T) T

Ternary logic function. If `cond` is true, the value obtained by evaluating `f` is returned. Otherwise `alt` is evaluated and returned.

func Max added in v0.16.0

func Max[T constraints.Ordered](x, y T) T

Max returns the largest of two ordered values. Note the values can be strings as well as numeric types.

func Min added in v0.16.0

func Min[T constraints.Ordered](x, y T) T

Min returns the smallest of two ordered values. Note the values can be strings as well as numeric types.

func Ref added in v0.16.0

func Ref[T any](v T) *T

Returns a pointer to a variable whose value is initialized to v. eg.

hp := functions.Ref("hello") // *hp == "hello"

Types

This section is empty.

Jump to

Keyboard shortcuts

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