gutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If[T any](cond bool, ifVal T, elseVal ...T) T

If returns ifVal if cond is true, elseVal otherwise. If cond is true, ifVal is returned, elseVal is ignored. If cond is false and elseVal is provided, elseVal is returned. If cond is false and elseVal is not provided, the zero value of T is returned.

func IfF

func IfF[T any](cond bool, ifFunc IfFunc[T], elseFunc ...IfFunc[T]) T

IfF returns the result of ifFunc if cond is true, the result of elseFunc otherwise. If cond is true, ifFunc is called, elseFunc is ignored. If cond is false and elseFunc is provided, elseFunc is called. If cond is false and elseFunc is not provided, the zero value of T is returned.

func IfFL

func IfFL[T any](cond bool, ifFunc IfFunc[T], elseVal T) T

IfFL returns the result of ifFunc if cond is true, elseVal otherwise. If cond is true, ifFunc is called, elseVal is ignored. If cond is false, elseVal is returned.

func IfFR

func IfFR[T any](cond bool, ifVal T, elseFunc IfFunc[T]) T

IfFR returns ifVal if cond is true, the result of elseFunc otherwise. If cond is true, ifVal is returned, elseFunc is ignored. If cond is false, elseFunc is called.

Types

type IfFunc

type IfFunc[T any] func() T

Jump to

Keyboard shortcuts

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