navid/haze / ea08ceb46539df9cf3ac396bc0bd66fc4f6b9adc630e1596e79b8e4d3101673a / samples/baseline_2.4/generic_multi_instantiation.hz

generic_multi_instantiation.hz

← samples/baseline_2.4 · 257 bytes · raw · download

pure fn choose[T](a T, b T, first bool) T
    : post r => r == a || r == b
    => if first {
        a
    } else {
        b
    }

fn main() {
    print(choose(1, 2, false))
    print(choose(true, false, true))
    print(choose("left", "right", false))
}