-
Notifications
You must be signed in to change notification settings - Fork 716
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
Explaining the concepts of Label (break and continue) in Dart #6451
base: main
Are you sure you want to change the base?
Conversation
This is the change for updating the webpage in the https://dart.dev/libraries/async/using-streams . Adding a Youtube video for the topic streams makes the user better to understand the topic and reduce the difficulties of them.
Thank you for this contribution! It looks like the staging docs did not build. Can you build the docs on your local machine and use the validator to validate your changes? https://github.com/dart-lang/site-www?tab=readme-ov-file#validate-your-changes |
Yeah sure mam, |
Welcome and I can't wait to see the final version! |
/gcbrun |
Visit the preview URL for this PR (updated for commit 099bc62): https://dart-dev--pr6451-j-manoj-06-patch-4-773qilc0.web.app |
Thank you, ma'am , That means a lot! |
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.
As per the issue , the Labels in Dart is explained with examples. Waiting for further improvements.
Fixes (#6289)
You haven't explained about label in this PR yet.
Converted this to a draft. When it's ready for review, let us know. ^_^ |
Sorry for the delay mam!! |
Hello @antfitch mam, |
Hello @samujjal-gogoi , |
src/content/language/branches.md
Outdated
@@ -138,6 +138,240 @@ switch (command) { | |||
} | |||
``` | |||
|
|||
### Labels in Dart |
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.
### Labels in Dart | |
### Labels |
Simple heading is preferred.
src/content/language/branches.md
Outdated
|
||
In Dart, labels are used to control nested loops(Loop inside Loop) using break and continue. Labels allow you to specify which loop to `break` or `continue`, rather than affecting the innermost loop by default. | ||
|
||
Here is the syntax for labels in Dart : |
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.
Here is the syntax for labels in Dart : | |
Here is the syntax for labels in Dart: |
Avoid space between the word and :
(I've found multiple occurrences, please find and fix them all).
src/content/language/branches.md
Outdated
@@ -138,6 +138,240 @@ switch (command) { | |||
} | |||
``` | |||
|
|||
### Labels in Dart | |||
|
|||
In Dart, labels are used to control nested loops(Loop inside Loop) using break and continue. Labels allow you to specify which loop to `break` or `continue`, rather than affecting the innermost loop by default. |
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.
In Dart, labels are used to control nested loops(Loop inside Loop) using break and continue. Labels allow you to specify which loop to `break` or `continue`, rather than affecting the innermost loop by default. | |
In Dart, labels are used to manage control flow in nested loops using `break` and `continue` statements. They allow you to specify which loop to break out of or continue, rather than affecting the innermost loop by default. |
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.
Prefer single-quote string over double-quote string.
src/content/language/branches.md
Outdated
|
||
``` | ||
|
||
In the above example, When `i == 2` and `j == 2`, `break outerLoop;` statement stops both inner and outer loops. So, the expected output would be : |
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.
In the above example, When `i == 2` and `j == 2`, `break outerLoop;` statement stops both inner and outer loops. So, the expected output would be : | |
In the above example, when `i == 2` and `j == 2`, `break outerLoop;` statement stops both inner and outer loops. So, the expected output would be: |
Besides this, I've found multiple occurrences, please find and fix them all.
src/content/language/branches.md
Outdated
|
||
``` | ||
|
||
#### Labels in for loop using `contiue` : |
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.
#### Labels in for loop using `contiue` : | |
#### Labels in for loop using `continue`: |
Found a typo!
src/content/language/branches.md
Outdated
} | ||
|
||
``` | ||
In the above example, the iteration for i = 2, j = 2 is skipped, and the loop moves directly to i = 3. As a result, the output would be: |
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.
In the above example, the iteration for i = 2, j = 2 is skipped, and the loop moves directly to i = 3. As a result, the output would be: | |
In the above example, the iteration for `i = 2` and `j = 2` is skipped, and the loop moves directly to `i = 3`. As a result, the output would be: |
Looks like you forgot to wrap the values with backticks?
src/content/language/branches.md
Outdated
|
||
``` | ||
|
||
In the above example, the loop skips i = 2, j = 2 and moves directly to i = 3. As a result, the output would be: |
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.
In the above example, the loop skips i = 2, j = 2 and moves directly to i = 3. As a result, the output would be: | |
In the above example, the loop skips `i = 2` and `j = 2` and moves directly to `i = 3`. As a result, the output would be: |
Same backticks issue here as well.
src/content/language/branches.md
Outdated
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.
Consider removing all unnecessary leading and trailing newlines in code blocks.
Also, consider documenting |
Sir, would you like me to document Labels in |
Yes, at the end of the file (i.e after |
Okay, @samujjal-gogoi sir. |
Hello @samujjal-gogoi sir, |
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 great so far!
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.
Prefer single quotes to satisfy the lint.
site-www/examples/analysis_options.yaml
Line 20 in 5d837cd
- prefer_single_quotes |
src/content/language/loops.md
Outdated
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.
Consider removing all unnecessary leading and trailing newlines in code blocks.
/gcbrun |
Added editorial changes.
Looking good! @J-Manoj-06, I've added editorial changes. Next, you'll need to connect the changes you made in In You want to add this line above all of your new samples and then generate the code excerpts to make sure that they run. If you have any issues, check out this doc: https://github.com/dart-lang/site-shared/tree/main/pkgs/excerpter#readme |
This PR improves the Dart documentation by adding detailed explanations and examples for the
break
andcontinue
statements in various loop structures (for, while, do-while, and nested loops).The changes have made in two directories:
/examples/language/lib/control_flow/branches.dart
/src/content/language/branches.md
This ensures and follows the contributing guidelines.
As per the issue , the Labels in Dart is explained with examples. Waiting for further improvements.
Fixes (#6289)
Best regards,
Manoj J