DEV Community

Discussion on: Solidity Quick Tip: Efficiently Swap Two Variables

Collapse
 
sashrika profile image
Sashrika Waidyarathna

let a = 1;
let b = 3;

[a, b] = [b, a];
console.log(a); // 3
console.log(b); // 1

Pretty much similar to javascript. Nice to learn that this is possible with solidity as well. Thanks for sharing..