#!/usr/bin/ruby
#
## https://rosettacode.org/wiki/Generic_swap#Sidef
#
func swap_1(Ref a, Ref b) {
var tmp = *a;
*a = *b;
*b = tmp;
}
func swap_2(Ref a, Ref b) {
(*a, *b) = (*b, *a);
}
var (a, b) = ([1], [2]);
swap_1(\a, \b);
assert_eq(a, [2]);
assert_eq(b, [1]);
swap_2(\b, \a);
assert_eq(a, [1]);
assert_eq(b, [2]);
say "** Test passed!";