Deviopath › Go

Swap Through Pointers

Medium · Pointers

*int is a pointer to an int. *p reads or writes the value at p. Swapping two ints through pointers changes the caller's variables.

Write Swap(a, b *int) that exchanges the values they point to.

Next: Rectangle Methods