mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-07 02:12:07 +03:00
Add a boolean operators guideline to the GDScript style guide
This commit is contained in:
@@ -131,6 +131,30 @@ necessary for order of operations, they only reduce readability.
|
||||
if (is_colliding()):
|
||||
queue_free()
|
||||
|
||||
Boolean operators
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Prefer the spelled-out versions of boolean operators (``and``/``or``) to their
|
||||
symbolic equivalents (`&&`/`||`). They're usually more readable as they're plain
|
||||
English words.
|
||||
|
||||
Add parentheses around boolean operators to avoid ambiguity, even if they're not
|
||||
strictly required. This makes long expressions easier to read.
|
||||
|
||||
**Good**:
|
||||
|
||||
::
|
||||
|
||||
if (foo and bar) or baz:
|
||||
print("condition is true")
|
||||
|
||||
**Bad**:
|
||||
|
||||
::
|
||||
|
||||
if foo && bar || baz:
|
||||
print("condition is true")
|
||||
|
||||
Comment spacing
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user