Back to Lo

Core Isnotempty

docs/data/core-isnotempty.md

1.53.0539 B
Original Source

Returns true if the value is not empty (not zero value) for comparable types. This is the opposite of IsEmpty.

go
result := lo.IsNotEmpty("")
// false (empty string)

result = lo.IsNotEmpty("hello")
// true

result = lo.IsNotEmpty(0)
// false (zero value for int)

result = lo.IsNotEmpty(42)
// true

result = lo.IsNotEmpty([]int{})
// false (empty slice)

result = lo.IsNotEmpty([]int{1, 2, 3})
// true

result = lo.IsNotEmpty(map[string]int{})
// false (empty map)

var ptr *int
result = lo.IsNotEmpty(ptr)
// false (nil pointer)