Files
lo/docs/data/core-isnotnil.md
T
2025-10-06 17:15:49 +02:00

729 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
IsNotNil isnil type_manipulation.go#L22 core type
func IsNotNil(x any) bool
core#type#isnotnil
core#type#isnil
core#type#empty
core#type#isempty
core#type#isnotempty
87

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.

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