class Util shared def swap(left as inout T, right as inout T) tmp as T = left left = right right = tmp def swapIfGreater(left as inout T, right as inout T) where T must be IComparable # 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(inout a, inout b) assert a == 2 and b == 1 # test constraint assert a > b Util.swapIfGreater(inout a, inout b) assert a < b