DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
bgadrian profile image
Adrian B.G.

The math trick works for numbers, but in Go:

a,b = b,a

(I think at the assembly level it uses a 3rd registry, but I'm not sure)

Collapse
 
codeandclay profile image
Oliver

Same in Ruby.