-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: is not
syntactic sugar
#1338
Comments
public class not {}
if(obj is not not)
1- obj is not of type 2- obj is of type |
@MkazemAkhgary : In this case one would have to provide either an alias or the parent namespace name, e.g.: namespace kek
{
public class not {}
public static class Program
{
public static int main(string[] argv)
{
...
if(obj is not kek.not)
...
}
}
} I do not think that that would be a bad solution, as one does rarely name a class |
This came up already so often, but somehow I got the feeling that it is the word if (foo is ! Bar) { ... } (this acutally looks a bit spanish |
I'd be for this if |
I don't think you cant have more than one english language is not a programming language. |
Order is significant in a switch statement. The first matching case is taken. If none match then a default label, if present, is taken. |
Having switch(point)
{
case Point2D(not 0, not 0): ...
case not Point3D(_, _, _): ...
default: ...
} |
@Richiban yes it would be useful especially in recursive patterns... but this of course begs the question: what if you want to match if the value is > 0? or any other comparison? would this feature be a dead end? |
but of course inverting a pattern is a much more general concept than inequality... i'm just a little worried that in this particular case (of that said, i would still prefer this as a general pattern rather than some syntactic sugar around |
There is syntax for this: if (foo is Bar == false) {
// Do something
} |
how about |
how about
yes, a little exaggeration, just to show you my feelings about |
This is csharplang, not applescriptlang 😄 |
@MkazemAkhgary How about using "isnot" instead of "is not"
|
I like |
If it starts with i, it's an interface, and thus should be written |
@CyrusNajmabadi Since @jnm2 likes informality, I think we should go with |
@CyrusNajmabadi If my nose was running money... |
Duplicate of #27 |
Already championed as part of #1350 |
Personally, I think this is much cleaner: if (foo aint bar)
{
} 😜 |
Closing because this was championed a while ago. |
I get that this is somewhat frivolous, but I think that
is cleaner than
I can't really think of any downsides to doing this, other than that it would take any amount development time for a relatively inconsequential syntax change. There are upsides however:
is
expression.An alternative to
is not
could beis!
or!is
, though those could be somewhat confusing.The text was updated successfully, but these errors were encountered: