Improvement of comparison operator #1128
Unanswered
andrey-messi
asked this question in
General
Replies: 3 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Honestly if I had a dollar for every time I could have used this in C#, I'd be making about $3/year. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If you've been using C# since the beginning, then you might have used this 50 times already. There are several "really useful" C# features I've used less than that over my career. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be more convinient to use
(minLimitStrict < var2 < var1 <= maxLimit)
instead of
(minLimitStrict < var2 && var2 < var1 && var1 <= maxLimit)
I know that here a compiler firstly evaluates first comparison operator (minLimitStrict < var2) and returns bool, so code:
(minLimitStrict < var2 < var1 <= maxLimit)
is not valid now.
But maybe it is possible to change a compiler's behavior and obligate to use parentheses when expected to return bool.
Or if it is not possible (for example for not breaking existing thirt-party code base), then it will be good to introduce new operators, for example <* and <=* :
(minLimitStrict <* var2 <* var1 <=* maxLimit)
Beta Was this translation helpful? Give feedback.
All reactions