Go code
number := 10
pointer := &number
fmt.Println(*pointer)Line-by-line explanation
- Number stores 10.
- The ampersand takes number’s address.
- Pointer stores that address.
- The star follows the address to read the value.
Expected output
10This is the expected result.
The & operator takes an address. The * operator follows a pointer to its value; this is called dereferencing.