Merged relational+boolean operators? #4980
-
Hi, when checking for out of bounds values, I often repeat the same var name over, and over. I'd like to have this variable name As I didn't found a way to achieve it in one operation, I propose the implementation of merged comparison operators (not every may have real use cases):
Would you find those usefull? Any thoughts about this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Since we have relational patterns now, you should be able to write this: if (j is < dateStart or > dateEnd) throw new NotImplementedException(); if (j is x or y or z or < 1000) throw new NotImplementedException(); But unfortunately they don't allow comparisons with variables, only constants. I'd much rather we augmented this existing syntax to allow non-constant comparisons; I think that's a lot better than introducing new operators. |
Beta Was this translation helpful? Give feedback.
Since we have relational patterns now, you should be able to write this:
But unfortunately they don't allow comparisons with variables, only constants. I'd much rather we augmented this existing syntax to allow non-constant comparisons; I think that's a lot better than introducing new operators.