func swap(Ref a, Ref b) { var tmp = *a *a = *b *b = tmp }
or:
func swap(Ref a, Ref b) { (*a, *b) = (*b, *a) }
func swap(Ref a, Ref b) { [*a, *b] » (b, a) }
The swap functions must be called with variable references.
var (x, y) = (1, 2) swap(\x, \y)
Last updated 1 year ago