Add a boolean operators guideline to the GDScript style guide

This commit is contained in:
Hugo Locurcio
2019-12-20 19:17:11 +01:00
parent 54f7f21cc7
commit c6fa2483f8

View File

@@ -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
~~~~~~~~~~~~~~~