-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Use the newly introduced is not
operator
#9777
Conversation
9e4cb5c
to
c47fb55
Compare
is not
operatoris not
operator
c47fb55
to
955417b
Compare
I wonder if there's any In any case, it's an innocent addition. Although, the simplification is... simpler, yeah, but may serve a different purpose. Assignments to variables and early returns like the code snippet above are pretty nifty. |
After all the searching, I have read the documentation guidelines. It turns out that, to make everything more concise, you should avoid using typed code. So it makes sense that the operator is not used outside of the typing tutorial, and I don't expect to find it in the class reference. At first I wanted to replace the operator in the expression, but then realised that this page also introduces the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another PR, #10085, also tries to document is not
in this section (though that PR only replaces the existing usage). One of these two PRs should be accepted.
You can also simplify the expression using the ``is not`` operator:: | ||
|
||
if body is not PlayerController: | ||
push_error("Bug: body is not PlayerController") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also simplify the expression using the ``is not`` operator:: | |
if body is not PlayerController: | |
push_error("Bug: body is not PlayerController") | |
You can also simplify the expression using the ``is not`` operator:: | |
if body is not PlayerController: | |
push_error("Bug: body is not PlayerController") |
This needs to be indented one level deeper, so it appears in the note block, since it is conceptually related to the earlier example.
You should also relocate this new is not
example to after the initial is
example and before the assert()
example. Note that you'll have to adjust the existing or ``assert()`` statement::
line to make sense.
955417b
to
8d4ab7a
Compare
8d4ab7a
to
6ef6ad8
Compare
Thanks for the review, I have applied all the feedback. I have also replaced an incorrectly used "expression". We don't have a separate documentation for the The other PR also suggest removing parentheses from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. This PR is a better way to document is not
than the alternate PR #10085.
Keeping the existing parentheses in the if not (body is PlayerController):
line makes sense to me, since it increases clarity if you don't know all the precedence rules. But I'm not an expert on the GDScript style standards we use for docs examples.
Merged. Thanks and congrats on your first merged contribution! Sorry this one took a bit :) |
Thank you too. I'm glad I could help :) |
Use the newly introduced
is not
operator instead ofnot (...) is
.Running the following regular expression:
(^|\`\`)\s*(if|while|.*=)(.)* not (|.* )is
I have found only one occurrence of the outdated code in the entire documentation.