Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
package main
import "fmt"
func swap(x, y string) (string, string) {
return y, x
}
func main() {
// call by reference
a, b := swap("Ali", "Mohammad")
fmt.Println(a, b)
// call by value
var a2 = "Ali2"
var b2 = "Mohammad2"
swap(a,b)
fmt.Println(a2, b2)
// call by value
a3, b3 := "Ali3", "Mohammad3"
swap(a,b)
fmt.Println(a3,b3)
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more