3 ms·
> [The “!” operator] is similar to Rust's `.unwrap()` but even more invisible. I had this thought too when reading Hare examples. When looking at a line like t
by kweingar 4y ago
> [The “!” operator] is similar to Rust's `.unwrap()` but even more invisible.
I had this thought too when reading Hare examples. When looking at a line like this:
fmt::println("Hello World!")!;
I notice that the punctuation at the end of the function call blends together, and the error assertion operator is easy to miss. I prefer Zig's convention of requiring the 'catch' keyword anytime a function call can raise an error.
An example from Zig's documentation:
const number = parseU64("1234", 10) catch unreachable;
This error assertion stands out (especially with syntax highlighting).
- ddevault 4y agoWe were discussing encouraging syntax highlighters to add something like this: https://l.sr.ht/Q_D-.png https://l.sr.ht/Q_D-.png