cond

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IIf

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

IIf returns ifTrue if condition is true, ifFalse otherwise

func IIfFunc

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

IIfFunc returns ifTrue() if condition is true, ifFalse() otherwise

Types

type Condition added in v0.16.0

type Condition[T any] interface {
	// Else returns the value if the condition is true, ifFalse otherwise
	Else(ifFalse T) T
	// ElseF returns the value if the condition is true, ifFalse() otherwise
	ElseF(ifFalse func() T) T
	// ElseIf returns the same condition if the condition is true, ifFalse otherwise
	ElseIf(cond bool, ifFalse T) Condition[T]
	// ElseIfF returns the same condition if the condition is true, ifFalse() otherwise
	ElseIfF(cond bool, ifFalse func() T) Condition[T]
}

Condition is a conditional statement that can be chained with else-if statements

func If added in v0.16.0

func If[T any](condition bool, value T) Condition[T]

If returns a Condition that can be used to chain else-if statements

func IfF added in v0.16.1

func IfF[T any](condition bool, value func() T) Condition[T]

IfF returns a Condition that can be used to chain else-if statements If the condition is true, the value is evaluated and returned

Jump to

Keyboard shortcuts

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