condition

package
v2.1.12 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 1 Imported by: 18

Documentation

Overview

Package condition contains some functions for conditional judgment. eg. And, Or, TernaryOperator ... The implementation of this package refers to the implementation of carlmjohnson's truthy package, you may find more useful information in truthy(https://github.com/carlmjohnson/truthy), thanks carlmjohnson.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And[T, U any](a T, b U) bool

And returns true if both a and b are truthy.

func Bool

func Bool[T any](value T) bool

Bool returns the truthy value of anything. If the value's type has a Bool() bool method, the method is called and returned. If the type has an IsZero() bool method, the opposite value is returned. Slices and maps are truthy if they have a length greater than zero. All other types are truthy if they are not their zero value.

func Nand

func Nand[T, U any](a T, b U) bool

Nand returns false iff both a and b are truthy.

func Nor

func Nor[T, U any](a T, b U) bool

Nor returns true iff neither a nor b is truthy.

func Or

func Or[T, U any](a T, b U) bool

Or returns false iff neither a nor b is truthy.

func TernaryOperator

func TernaryOperator[T, U any](isTrue T, ifValue U, elseValue U) U

TernaryOperator checks the value of param `isTrue`, if true return ifValue else return elseValue

func Xnor

func Xnor[T, U any](a T, b U) bool

Xnor returns true iff both a and b or neither a nor b are truthy.

func Xor

func Xor[T, U any](a T, b U) bool

Xor returns true iff a or b but not both is truthy.

Types

This section is empty.

Jump to

Keyboard shortcuts

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