Swap the value of two variables : Variables « Language Basics « Ruby
- Ruby
- Language Basics
- Variables
Swap the value of two variables
a, B = 1, 2 # Same as x = 1; y = 2
a, b = b, a # Swap the value of two variables
Related examples in the same category