The value may be an error (T!) or missing (T?), but a plain T is expected. Auk makes
failure visible: decide what happens in the bad case with ? (pass it up), else (a
fallback) or ! (panic).
Wrong#
fn count(s: str): int! {
let n: int = int.parse(s)
n + 1
}Fixed#
fn count(s: str): int! {
let n: int = int.parse(s)?
n + 1
}Common causes#
- Calling a fallible function (
fs.read,int.parse,xs.first()) without?orelse. - In a function that can't fail itself, use
else:int.parse(s) else 0.