Iterator和Iterable之间的区别 [英] Difference between Iterator and Iterable

查看:150
本文介绍了Iterator和Iterable之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Iterator和Iterable有什么区别?是另一种亚型吗?在某些实际应用中实际有什么区别?

What is the difference between Iterator and Iterable? Is one sub-type of the other or not? What are the actual differences in some real applications?

我正在尝试阅读一些教程和规范,但是它们都很复杂.

I am trying to read some tutorials and specifications, but they are all very complicated.

(如果有帮助,我正在使用ES6和Babel.)

(I am using ES6 and Babel, if that helps.)

推荐答案

来自探索ES6 Axel Rauschmayer博士撰写:

From Exploring ES6 by Dr. Axel Rauschmayer:

可迭代的是一种数据结构,希望使其元素可被公众访问.它通过实现一个键为Symbol.iterator的方法来实现.该方法是迭代器的工厂.

An iterable is a data structure that wants to make its elements accessible to the public. It does so by implementing a method whose key is Symbol.iterator. That method is a factory for iterators.

迭代器是用于遍历数据结构的元素的指针(请考虑数据库中的游标).

An iterator is a pointer for traversing the elements of a data structure (think cursors in databases).

这篇关于Iterator和Iterable之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆