x = [ 5 , 10 ] work = x[ 0 ] x[ 0 ] = x[ 1 ] x[ 1 ] = work x.length.times { |i| printf( "x[ %d ] = %d\n" , i , x[ i ] ) }