-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: creating tasks #34
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: hunknownz <[email protected]>
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.
写的很细致, 提了几点修改建议.
|
||
### 代码逐行解释 | ||
|
||
- `struct Task`:这是定义一个名为 Task 的结构体。结构体类似于一个自定义的数据类型,包含了我们希望存储在一起的多个变量。 |
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.
"结构体类似于一个自定义的" => "结构体是一个自定义的". 描述定义的时候, 尽量用确定的词语, 这样会精确一些. 类比的时候用 “类似于”.
- `tasks[nextTaskId] = Task(nextTaskId, _content, false); | ||
nextTaskId++;`,创建并存储新任务 | ||
- `tasks[nextTaskId]`:在 tasks 映射中,使用当前的 nextTaskId 作为键。 | ||
- `=`:赋值操作符,将右侧的值赋给左侧的变量。 |
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.
这种最初级的语法, 可以不用解释.
- _content:任务的内容,由函数参数提供。 | ||
- false:任务的初始完成状态,默认为未完成(false)。 | ||
- `nextTaskId++;`,更新任务 ID | ||
- `++`:自增运算符,将变量的值加 1。 |
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.
同上, 可以不用解释
close #13