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

> 1) More readable code. The classic is foo.Bar(true). It breaks the flow of reading to have to hover and see what that 'true' means. Much nicer to see foo.bar(launchMissiles: true).

This is a case where I've started using Enums in Java. For example:

    foo.bar(LaunchMissiles.YES);
In Rust, you could have a macro to make defining these types easier (and have it automatically generate to_bool and from_bool methods):

    named_bool!(LaunchMissiles);
    foo.bar(LaunchMissiles::Yes);


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

Search: