Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> const foo = potentiallyErrorReturningFunc() catch { 0 };

Nitpick, but AFAIK this won't work and needs to be rewritten either to:

    const foo = potentiallyErrorReturningFunc() catch 0;
...or to:

    const foo = potentiallyErrorReturningFunc() catch blk: { break :blk 0; }
(I wish there would be a more convenient way to return a value from a scope block, not necessarily with a "dangling expression" like Rust, but maybe at least getting rid of the label somehow)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: