Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func If ¶
If is the replacement ternary operator in Go
Usage:
ternary.If(condition bool, elementReturnedIfTrue, elementReturnedIfFalse)
Example:
ternary.If(true, "foo", "bar") // returns "foo" ternary.If(false, "foo", "bar") // returns "bar"
func IfFunc ¶ added in v1.0.1
IfFunc implements a given function using the chosen element as parameter
Usage:
ternary.If(condition bool, elementPassedIfTrue, elementPassedIfFalse, function func(element))
Example:
ternary.If(true, "foo", "bar", func(e any) { return fmt.Sprintf("%v", e) }) // returns "foo"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.