-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wrapping example using parentheses and backslashes #9156
base: master
Are you sure you want to change the base?
Conversation
Code examples taken from here: https://www.reddit.com/r/godot/comments/co3pu2/comment/ewfp2dy/
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I'm unsure if we should suggest the parentheses version, we discourage unnecessary parentheses and these are unnecessary as the continuation method exists Let's get an opinion from the GDScript team |
Let me clarify that the main goal of this PR is to demonstrate all possible line wrapping options. You can highlight a recommended option, but it's good practice to show all the available options. |
Sure, but the same page says using parentheses unnecessarily is bad practice, so it doesn't make sense to me to have a later example that contradict it, parentheses around the conditions is not GDScript style, this is a style guide, not instructions on how to wrap lines in general IMO |
cc @dalexeev / @godotengine/gdscript |
I think there should only be one recommended style on this page. The fact that backslash can be used to wrap long lines is already mentioned in the GDScript reference: one, two. But indeed, the style guide does not answer which option is preferable. Looking at GDScript reference, Python, On the other hand, when adding a new rule to the style guide, we should look at the established practices in the community. What style do we use in demo projects, what style do popular addons and projects use? |
if ($Sprite.animation == "back_crouch" | ||
or $Sprite.animation == "front_crouch" | ||
or $Sprite.animation == "horizontal_crouch"): | ||
do_something() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($Sprite.animation == "back_crouch"
or $Sprite.animation == "front_crouch"
or $Sprite.animation == "horizontal_crouch"
):
do_something()
or
if (
$Sprite.animation == "back_crouch"
or $Sprite.animation == "front_crouch"
or $Sprite.animation == "horizontal_crouch"
):
do_something()
or
if (
$Sprite.animation == "back_crouch"
or $Sprite.animation == "front_crouch"
or $Sprite.animation == "horizontal_crouch"
):
do_something()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to use the second one personally, as it's what the GDScript style guide recommends.
Code examples taken from here: https://www.reddit.com/r/godot/comments/co3pu2/comment/ewfp2dy/