typeover
curriculum

Curriculum Types & methods Pointers exercise 1 · mcq

Pointers

TypeScript hides pointer-vs-value behind "objects are references, primitives copy". Go makes the distinction EXPLICIT with two operators: - &x — ADDRESS-OF: produces a pointer to x. - *p — DEREFERENCE: reads through the pointer to the value. Pick the line that prints 42 given: ``go x := 42 p := &x ` …where p holds the address of x` and you want to print the value at that address.

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.