Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Update 08-generics.md #29

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Update 08-generics.md #29

merged 1 commit into from
Jan 16, 2024

Conversation

hshq
Copy link
Contributor

@hshq hshq commented Jan 14, 2024

fix .typo

@@ -74,7 +74,7 @@ fn IntArray(comptime length: usize) type {

乍一看,这可能并不整齐。但除了匿名和嵌套在一个函数中之外,我们的结构看起来就像我们目前看到的其他结构一样。它有字段,有函数。你知道人们常说『如果它看起来像一只鸭子,那么就就是一只鸭子』。那么,这个结构看起来、游起来和叫起来都像一个正常的结构,因为它本身就是一个结构体。

希望上面这个示例能让你熟悉返回类型的函数和相应的语法。为了得到一个更典型的通用结构,我们需要做最后一个改动:我们的函数必须接受一个类型。实际上,这只是一个很小的改动,但 `type` 会比 `usize` 更抽象,所以我们慢慢来。让我们做一个大改动,修改之前的 `IntList`,使其能与任何类型一起工作。我们先从基本结构开始:
希望上面这个示例能让你熟悉返回类型的函数和相应的语法。为了得到一个更典型的范型,我们需要做最后一个改动:我们的函数必须接受一个类型。实际上,这只是一个很小的改动,但 `type` 会比 `usize` 更抽象,所以我们慢慢来。让我们进行一次飞跃,修改之前的 `IntList`,使其能与任何类型一起工作。我们先从基本结构开始:
Copy link
Member

Choose a reason for hiding this comment

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

进行一次飞跃是字面意思,不如之前的翻译好了。

Copy link
Contributor Author

@hshq hshq Jan 15, 2024

Choose a reason for hiding this comment

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

翻译的好坏看个人品味,不好比较,在这里也不是重点。
你看整个段落:...我们需要做最后一个改动...这只是一个很小的改动...让我们做一个大改动...
是不是矛盾了,前一句刚说了这是“小改动”,紧接着又说是“大改动”?
“小改动”产生大的”飞跃“,这才是本意吧。

Copy link
Member

Choose a reason for hiding this comment

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

确实,我之前理解有误。

Copy link
Member

@jiacai2050 jiacai2050 left a comment

Choose a reason for hiding this comment

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

LGTM

@jiacai2050 jiacai2050 merged commit abc8da6 into zigcc:main Jan 16, 2024
1 check passed
@hshq hshq deleted the patch-1 branch January 17, 2024 07:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants