Single line swapping in Ruby

Submitted by Karthikeyan on Fri, 26/10/2012 - 07:15

The values of the variables number1 & number2 can be interchanged in single line


number1 = 78
number2 = 25
print "number1 = ", number1, " number2 = ",number2
puts
number1, number2 = number2, number1
print "number1 = ", number1, " number2 = ",number2
Output

number1 = 78 number2 = 25
number1 = 25 number2 = 78