24 ms·
For errors the ? operator is both correct and easy most of the time. But for options it's trickier. Unless the surrounding function is structured just right, t
by duckerude 6y ago
For errors the ? operator is both correct and easy most of the time.
But for options it's trickier. Unless the surrounding function is structured just right, the equivalent to Typescript's and Kotlin's ? operator is .map()/.and_then(), and that's pretty ugly. .unwrap() is easier.
Try blocks might help.