Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- a := "A"
- b := "B"
- fmt.Println(a, b) // "A" "B"
- Swap(&a, &b) // the swap function is implemented
- fmt.Println(a, b) // "B" "A"
- }
- func Swap(x, y *string) { // x and y pointers to *string
- *x, *y = *y, *x // swap,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement