0 votes

I can completely understand why, with more than one line inside the if statement, it makes sense to put them on sequential lines. But with a one liner, it looks and reads better. Please help me understand, so I can buy into this uglier formatted code:

# Pretty
if my_bool: do_one_thing()

vs

 # !Pretty
 if my_bool:
        do_one_thing()
in Engine by (146 points)

1 Answer

+1 vote
Best answer

"Looks and reads better" is purely your opinion, others will disagree. Personally, I find it less readable because now there are two statements on one line, and two different ways to read an if.

If you're happy with it in your code, feel free, nobody is going to mind. However, the style guide is designed for wide usage and consistency. There's no need for a different rule for one-line versus multi-line conditionals.

by (20,895 points)
selected by

Thank you for the take.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.