Request clarification or change on the use of the 'not' operator on strings. #10030
Labels
area:class reference
Issues and PRs about the class reference, which should be addressed on the Godot engine repository
bug
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 usingis_empty()
to check instead.The intention may also have been to state that the
not
operator cannot be used to flip or toggle the value, as inmy_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 thatnot ""
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
The text was updated successfully, but these errors were encountered: