Parallel Assignment
/* * A nonsense program to exercise parallel assignment. */ package main import "fmt" func main() { // Permutations. the := "the" word := "word" is := "is" gow := "go" for i := 1; i <= 5; i++ { fmt.Printf("%s %s %s %s\n", the, word, is, gow) //the, word, is, gow = word, gow, the, is the, word, is, gow = gow, is, the, word } fmt.Printf("\n") // Each rhs value is computed before any values are assigned a := 3 b := 500 for a <= b { fmt.Printf("%d %d\n", a, b) a, b = a*(b/100), b + (a/3) } fmt.Printf("\n") // Most obvious use: exchange. fmt.Printf("%d %d\n", a, b) a, b = b, a fmt.Printf("%d %d\n", a, b) }