cond

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ternary

func Ternary[T any](condition bool, ifTrue, ifFalse T) T

Ternary operator with a condition and two possible results. The condition is evaluated and the first result is returned if it is true, otherwise the second result is returned.

cond.Ternary(true, "yes", "no") // "yes"
cond.Ternary(false, "yes", "no") // "no"

💣 Since go doesn't support lazy evaluation, so dereference a pointer will cause panic.

func TernaryFunc added in v0.4.0

func TernaryFunc[T any](condition bool, ifTrue, ifFalse func() T) T

Types

This section is empty.

Jump to

Keyboard shortcuts

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