DEV Community

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

Collapse
 
leoat12 profile image
Leonardo Teteo

This was my solution as well. I honestly never thought about this problem seriously and went for a third variable every time. I'm taking capacity for granted. I learned my lesson. u.u

Collapse
 
sathwikmatsa profile image
Sathwik Matsa • Edited

Wait.. readability of your code is also important!

Thread Thread
 
theoutlander profile image
Nick Karnik

Sure, it is. That's when you modularize your code and make an inline method or macro out of this.