Recall & Review
beginner
What does the address operator (&) do in Go?
The address operator (&) gives the memory address of a variable. It lets you find where the variable is stored in memory.
Click to reveal answer
beginner
What does the dereference operator (*) do in Go?
The dereference operator (*) lets you access or change the value stored at a memory address (pointer). It "follows" the pointer to the actual data.
Click to reveal answer
beginner
Given: var x int = 10; p := &x; What is *p?
*p is 10, the value stored at the memory address p points to (which is x's value).
Click to reveal answer
intermediate
How do you change the value of a variable using a pointer in Go?
Use the dereference operator (*) on the pointer to assign a new value. For example, *p = 20 changes the value at the address p points to.
Click to reveal answer
intermediate
Why are address and dereference operators useful in Go?
They let you work directly with memory addresses, which helps with efficient data handling, sharing data without copying, and building complex data structures like linked lists.Click to reveal answer
What does the & operator do in Go?
✗ Incorrect
The & operator returns the memory address of a variable.
What does *p mean if p is a pointer in Go?
✗ Incorrect
*p accesses the value stored at the memory address that p points to.
How do you get the address of variable x in Go?
✗ Incorrect
Use &x to get the memory address of variable x.
If p := &x, what does *p = 5 do?
✗ Incorrect
*p = 5 changes the value of x to 5 because p points to x.
Why use pointers in Go?
✗ Incorrect
Pointers let you access and manipulate memory addresses directly, which can improve efficiency.
Explain how the address (&) and dereference (*) operators work together in Go.
Think about how you find a house address and then enter the house to see what's inside.
You got /3 concepts.
Describe a simple example in Go where you use a pointer to change a variable's value.
Start with a number, get its address, then change the number through the pointer.
You got /5 concepts.