

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Introduction to Pointers
incomplete
2: References
incomplete
3: Pass by Reference
incomplete
4: Pointers Quiz
incomplete
5: Nil Pointers
incomplete
6: Pointer Receivers
incomplete
7: Pointer Receiver Code
incomplete
8: Pointer Performance
incomplete
9: Update Balance
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
As we have learned, a variable is a named location in memory that stores a value. We can manipulate the value of a variable by assigning a new value to it or by performing operations on it. When we assign a value to a variable, we are storing that value in a specific location in memory.
x := 42
// "x" is the name of a location in memory. That location is storing the integer value of 42
A pointer is a variable that stores the memory address of another variable. This means that a pointer "points to" the location of where the data is stored, not the actual data itself.
The * syntax defines a pointer:
var p *int
The & operator generates a pointer to its operand.
myString := "hello"
myStringPtr := &myString
Fix the bug in the getMessageText function. It's supposed to return a nicely formatted message to the console containing an SMS's recipient and message body. However, it's not working as expected. Run the code and see what happens, then fix the bug.