Back to Lo

Core Isnotnil

docs/data/core-isnotnil.md

1.53.0425 B
Original Source

Returns true if the input is not nil and does not point to a nil value. This works with pointers, interfaces, maps, slices, channels, and functions.

go
result := lo.IsNotNil(nil)
// false

var ptr *int
result = lo.IsNotNil(ptr)
// false

result = lo.IsNotNil(42)
// true

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

var iface interface{}
result = lo.IsNotNil(iface)
// false

iface = 42
result = lo.IsNotNil(iface)
// true