logoalt Hacker News

userbinator • yesterday at 9:13 PM • 1 reply • view on HN

I would actually prefer chained ternaries over more verbose if/else expressions with duplicated LHS, so this does go back to the argument about "taste".


Replies

AlienRobot • yesterday at 9:46 PM

This is one of the things I like about Rust. You can have both.

    let foo = {
        if bar {
            1
        } else if baz {
            2
        } else {
            3
        }
    };
Unfortunately not all languages are Rust.
➕ show 1 reply