Skip to content
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

精读《设计模式 - Iterator 迭代器模式》 #298

Closed
ascoders opened this issue Jan 24, 2021 · 1 comment
Closed

精读《设计模式 - Iterator 迭代器模式》 #298

ascoders opened this issue Jan 24, 2021 · 1 comment

Comments

@ascoders
Copy link
Owner

ascoders commented Jan 24, 2021

迭代器模式是遍历集合对象的通用方法,好处是遍历者不需要了解集合对象的内部结构,符合迪米特法则。


精读《设计模式 - Iterator 迭代器模式》

@yaowencurry
Copy link

next() { return this.list.values[this.list.index] // 注意边界情况,这里就不展开 this.list.index++ }

这里是不是写错了,都return了,后面的this.list.index++应该没用了吧。

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

No branches or pull requests

2 participants