Back to Lo

Core Toptr

docs/data/core-toptr.md

1.53.0219 B
Original Source

Returns a pointer to the provided value.

go
ptr := lo.ToPtr(42)
// *int pointing to 42

ptr = lo.ToPtr("hello")
// *string pointing to "hello"

ptr = lo.ToPtr([]int{1, 2, 3})
// *[]int pointing to []int{1, 2, 3}