Skip to content
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

Request clarification or change on the use of the 'not' operator on strings. #10030

Open
XandaPanda42 opened this issue Oct 2, 2024 · 0 comments
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository bug

Comments

@XandaPanda42
Copy link

Your Godot version:

4.1.3 to 4.3

Issue description:

The "String (GDscript)" page (Description, Paragraph 3) incorrectly states that "The not operator cannot be used. Instead, is_empty() should be used to check for empty strings." when referring to boolean string comparison.

However, the code below works as expected and does not reflect the wording of the doc page.
var my_str: String = ""

if my_str:
print("my_str evaluates to false and this will never be printed.")
if not my_str:
print("This evaluates to true as my_str does **not** evaluate to true.")

I'm not certain of the original intention, but I believe the page should be changed to: "The not operator should not be used." leading the user to prefer using is_empty() to check instead.

The intention may also have been to state that the notoperator cannot be used to flip or toggle the value, as in my_bool = not my_bool.

Though this might seem obvious, as just using not like this (my_str = not my_str) can't parse as strings have no inherent 'true' state to "flip" to, I think it still bears clarification.

Additional info/Thoughts of a random Pedant:

my_str = "a very full string"

Technically, not my_str could be the same as "" but this can't work in reverse as there is an infinite number of strings that not "" could become, unlike a true/false toggle, which only has one option.

URL to the documentation page:

https://docs.godotengine.org/en/stable/classes/class_string.html

If you know how to fix the issue you are reporting please
consider opening a pull request. We provide a tutorial on
using git here: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html,
writing documentation at https://docs.godotengine.org/en/stable/community/contributing/docs_writing_guidelines.html
and contributing to the class reference here: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html

@AThousandShips AThousandShips added the area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository label Oct 2, 2024
@fire fire changed the title Request clarrification or change on the use of the 'not' operator on strings. Request clarification or change on the use of the 'not' operator on strings. Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository bug
Projects
None yet
Development

No branches or pull requests

2 participants