Skip to content

Proposal/Discussion: Negation of if/while Condition #568

@HaloFour

Description

@HaloFour

There have been a couple of proposals exploring how improve the readability of conditional operations that involve negation. Some developers find the nesting of parenthesis to be unattractive at best and easy to miss at worst.

I would like to explore the potential of allowing for a negation prefix operator ! to appear outside of the required parenthesis for if and while conditions so that the condition is effectively reversed:

if !(foo is Bar bar)
{
    // stuff
}

while !(finished)
{
    // stuff
}

do
{
    // stuff
}
while !(finished);

Certainly minor and the argument can definitely be made that the negation is even less obvious. It also doesn't address concerns with operators that would still require parenthesis, e.g. is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions