I am currently learning Golang, and i decided to write few simple algorithm for learning the syntax. i hope it's not already answers but i didn't found it ..
I have a problem for swapping string
func swap(str1, str2 string) {
/*
* Also possible :
* str1, str2 = str2, str1
*/
// str1, str2 = str2, str1
tmp := str1
str1 = str2
str2 = tmp
}
func main() {
a := "World !"
b := "Hello"
swap(a, b)
fmt.Printf("a=%s
b=%s
", a, b)
}
Why this code didn't work ?