Negation of subclass properties suggestion


#1

Sometimes you need to access a boolean property, that is placed deep down the inheritance hierarchy, and to keep things particularly readable and clear, you want to leave it written so.

For example:

Class.InnerClass.isPropTrue

Instead of:

isInnerClassPropTrue = true/false, 

the name of which is less clear to the reader.

I had a similar situation in code, when I needed to negate such an expression and had to do it like this:

!Class.InnerClass.isPropTrue

And I realized how strange sometimes it is to put a negation mark before the class name and not property. But still, you can’t do this:

Class.InnerClass.!isPropTrue

Or anything similar that could do the same thing.

Unfortunately, such syntax may conflict with “not-null assertion” mark (!. or !!) , and that’s sad, so I wouldn’t insist on that one.

But what about the idea itself?


#2

Class.InnerClass.isPropTrue.not()


#3

You are correct, thanks. Should have known before, my fault.

Nevertheless, it does look a bit redundant here, right?)
Any other ideas? :smile: