HUGO
Menu
GitHub 87548 stars Mastodon

and

Returns the first falsy argument. If all arguments are truthy, returns the last argument.

Syntax

and VALUE...

Returns

any

假值包括 false0、任何 nil 指针或接口值、任何长度为零的数组、切片、映射或字符串,以及零值 time.Time

其他所有值都是真值。

The and function evaluates the arguments from left to right, and returns when the result is determined.

{{ and 1 0 "" }} → 0 (int)
{{ and 1 false 0 }} → false (bool)

{{ and 1 2 3 }} → 3 (int)
{{ and "a" "b" "c" }} → c (string)
{{ and "a" 1 true }} → true (bool)

{{ and false (math.Div 1 0) }} → false (bool)

有关更多信息,请参阅 Go 的 text/template 文档。


Last updated: January 1, 0001
Improve this page