Skip to content

Comments

docs(loop): 改进 while 循环 continue 表达式章节#308

Merged
jinzhongjia merged 2 commits intozigcc:mainfrom
lilhammerfun:docs/improve-while-continue
Feb 20, 2026
Merged

docs(loop): 改进 while 循环 continue 表达式章节#308
jinzhongjia merged 2 commits intozigcc:mainfrom
lilhammerfun:docs/improve-while-continue

Conversation

@lilhammerfun
Copy link
Contributor

Summary

  • 重写 continue 表达式章节,先给出定义和代码示例,再结合基本示例中的死循环问题解释其作用
  • 新增 while_continue_fix 代码示例,展示 continue 表达式如何解决手动递增被跳过的问题
  • 补充执行顺序说明和 break 不触发 continue 表达式的提示

Test plan

  • zig build 编译通过
  • bun dev 本地预览确认渲染效果

重写 continue 表达式的说明,结合基本示例中的死循环问题,
解释 continue 表达式的执行时机和作用。
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lilhammerfun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在通过重写 while 循环中 continue 表达式的文档,显著提升其清晰度和实用性。更新后的内容不仅提供了更详细的定义和示例,还特别强调了 continue 表达式在防止潜在死循环方面的关键作用,并新增了一个具体的代码示例来直观地演示这一机制,从而帮助读者更好地理解和应用这一控制流语句。

Highlights

  • 改进 while 循环 continue 表达式章节: 重写了 continue 表达式的定义和示例,并解释了其如何解决基本示例中的死循环问题。
  • 新增代码示例: 增加了 while_continue_fix 代码示例,展示了 continue 表达式如何避免手动递增被跳过。
  • 补充说明: 补充了循环执行顺序的说明,并提示 break 不会触发 continue 表达式。
Changelog
  • course/basic/process_control/loop.md
    • 重写了 continue 表达式的定义,明确了其执行时机(每轮循环体结束后、下一轮条件判断之前)。
    • 引入了 while_continue_fix 代码示例的引用。
    • 详细说明了 while 循环中包含 continue 表达式的执行顺序。
    • 解释了 continue 表达式如何解决在特定条件下可能导致的死循环问题。
    • 添加了一个提示,说明 break 语句会直接退出循环,因此不会执行 continue 表达式。
    • 澄清了 continue 表达式可以是单个语句或代码块。
  • course/code/15/loop.zig
    • 新增了 while_continue_fix 代码段,演示了如何在 while 循环中使用 continue 表达式来确保循环变量 i 即使在 if (i == 5) continue; 的情况下也能正确递增,从而避免死循环。
Activity
  • 已通过 zig build 编译。
  • 已通过 bun dev 在本地预览并确认渲染效果。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这次改进非常好地解释了 continue 表达式的作用,特别是通过对比基本示例中的死循环问题,让读者更容易理解其必要性。新增的代码示例和执行顺序说明也非常清晰。针对文档的准确性和代码风格的一致性,我提出了一些小的改进建议。

// 将while语句的基础代码用continue表达式改写
var i: usize = 0;
while (i < 10) : (i += 1) {
if (i == 5) continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与该文件中的其他 if 语句风格保持一致,建议为 if 块添加大括号。

                if (i == 5) {
                    continue;
                }

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Member

@jinzhongjia jinzhongjia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢 pr

@jinzhongjia jinzhongjia merged commit 6db8f3a into zigcc:main Feb 20, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants