v/vlib/v/checker/tests/optional_or_block_none_err.vv

23 lines
256 B
V

module main
struct Animal {
mut:
height u8
}
fn new_animal(height u8) ?Animal {
if height < 10 {
return error('Too small to be an animal!')
}
return Animal{
height: height
}
}
fn main() {
mut dog := new_animal(9) or { none }
println(dog)
}