Swapping using Functions in GO

Swapping two variables using GO Language

Source code :


package main

import "fmt"

func swap(x, y int) (int, int) {
	return y, x
}

func main() {
	a, b := swap(1, 2)
	fmt.Println(a, b)
}

Output :

2 1

Output :


                

Comments :