Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Calinou | |
Old Version | Published before Godot 3 was released. |
I want to write an if
statement that spans over several lines, how do I do that?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Calinou | |
Old Version | Published before Godot 3 was released. |
I want to write an if
statement that spans over several lines, how do I do that?
Reply From: | Calinou |
You can use parentheses around the if
statement, or backslashes before the newline (which should work anywhere).
Take this script for example:
func _ready():
if (2 == 2
and 3 == 3
and 4 == 4
and 5 == 5
and 6 == 6):
print("The parenthesis way of putting 'if' statements on multiple lines.")
if 2 == 2 \
and 3 == 3 \
and 4 == 4 \
and 5 == 5 \
and 6 == 6:
print("The backslash way of putting 'if' statements on multiple lines.")