Beginner Go (Golang)
Q19 / 100

What does new() do in Go?

Correct! Well done.

Incorrect.

The correct answer is B) Allocates memory for a type and returns a pointer to its zero value

B

Correct Answer

Allocates memory for a type and returns a pointer to its zero value

Explanation

p := new(int) allocates an int zeroed to 0 and returns *int. For structs, prefer &MyStruct{} which can also initialize fields.

Progress
19/100