Back to Lo

Core Empty

docs/data/core-empty.md

1.53.0431 B
Original Source

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

go
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)