typeover
curriculum

Curriculum Types & methods Pointers exercise 2 · mcq

Pointers

Pick the line that DECLARES a pointer p holding the address of x. Exercise 1 went the other direction (deref to read); this exercise goes the FIRST direction (take the address to create the pointer in the first place). Given x := 42, what line gives you a *int pointing at x?

TypeScript reference
Pick the idiomatic Go translation

About this theme

&x takes the address of x. *p dereferences p. Pointers in Go are pointers — they're not garbage-collector-hostile, they don't do arithmetic (no p++), and they don't bite. They're the explicit version of "by reference" — TypeScript hides this behind "objects are references," Go makes it visible.