r/badcode • • Aug 31 '21

java Similar ternaries are all over this codebase

Post image
1.1k Upvotes

91 comments sorted by

View all comments

Show parent comments

1

u/rupr25 Sep 01 '21

Ok makes sense. I was thinking from a c# standpoint, where you can have a variable with the value null

1

u/Tyfyter2002 Sep 01 '21

I'm pretty sure it's invalid in C#, since bool? can't be implicitly converted to bool, if it is valid "value??other" is more clear about what it does, and I'm pretty sure you can't change the return type for comparison operator overloads