golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.53k stars 521 forks source link

tour: [the variables are reversed] #1535

Closed quki3 closed 2 months ago

quki3 commented 10 months ago

Context: https://go.dev/tour/basics/6

package main

import "fmt"

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

func main() { a, b := swap("hello", "world") fmt.Println(a, b) }

output // world hello WHAT DO I EXPECT? ouput // hello word

ALTree commented 2 months ago

The two strings were swapped, the output is correct.