Fix: Clarify Range Expression by Adding Parentheses for Clarity #4659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Explanation
Clarified Range Expression:
Parentheses have been added around
(y + 1)
in the range expression1..(y + 1)
to improve clarity. This ensures that the precedence of the+
operator in the expression is clear and avoids any confusion regarding the evaluation order.Improved Readability for Beginners:
The added parentheses help beginners better understand the order of operations within the range expression. This change makes it easier to follow the logic and ensures that the range is correctly interpreted as intended.
Updated Example for Better Understanding:
The code example has been modified to make the behavior of the range operation more understandable, particularly in how the upper bound is calculated. This update will help developers easily grasp how ranges work in Kotlin, with a focus on operator precedence.
Purpose of Changes:
The goal of this change is to enhance the clarity of the example and ensure that developers—especially beginners—understand how the range expression works. By adding parentheses, the expression is now more explicit, and it eliminates any ambiguity about the order in which the
+
operation is applied.These updates aim to improve the overall documentation by providing clearer and more accessible examples for developers, making it easier to understand key concepts in Kotlin.