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

785 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
Empty empty type_manipulation.go#L132 core type
func Empty[T any]() T
core#type#empty
core#type#isempty
core#type#isnotempty
core#type#coalesceorempty
core#type#coalescesliceorempty
core#type#coalescemaporempty
120

Returns the zero value for the specified type. This is useful when you need an empty value of a specific type.

result := lo.Empty[string]()
// "" (zero value for string)

result = lo.Empty[int]()
// 0 (zero value for int)

result = lo.Empty[[]int]()
// []int{} (zero value for slice)

result = lo.Empty[map[string]int]()
// map[string]int{} (zero value for map)

result = lo.Empty[*int]()
// nil (zero value for pointer)