generic_swap_1.sf 171 B

12345678910111213141516
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Generic_swap
  4. #
  5. func swap(Ref a, Ref b) {
  6. (*b, *a) = (*a, *b);
  7. }
  8. var (x, y) = (1, 2);
  9. swap(\x, \y);
  10. say x;
  11. say y;