class Util

	shared

		def swap<of T>(left as inout T, right as inout T)
			tmp as T = left
			left = right
			right = tmp

		def swapIfGreater<of T>(left as inout T, right as inout T)
			where T must be IComparable<of T>  # test constraint
			if left.compareTo(right) > 0
				tmp as T = left
				left = right
				right = tmp


class Test

	def main is shared
		a = 1
		b = 2
		Util.swap<of int>(inout a, inout b)
		assert a == 2 and b == 1

		# test constraint
		assert a > b
		Util.swapIfGreater<of int>(inout a, inout b)
		assert a < b

