navid/haze / 29e7ef5e690b244d506a169b7a4f892c737395b40bafffaedbaf7b650bf94bb8 / 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))
}