Examples · learn/07-errors · 130 of 339
question-option
? works on Option too, in a function that returns an Option.
tin run examples/learn/07-errors/question-option.tin// ? works on Option too, in a function that returns an Option.
fn sumOf(a: string, b: string): Option<int> {
let x = parseInt(a)?
let y = parseInt(b)?
Some(x + y)
}
fn main() {
print(sumOf("2", "40"))
print(sumOf("2", "forty"))
}