Values & References4 / 15
Up next

new allocates a zero value

package main

import "fmt"

func main() {
	// new(int) points at a fresh zero value
	p := new(int)
	fmt.Println(*p) // 0
	*p = 7
	fmt.Println(*p)
}
What you're solving

new(T) returns a *T