课程: Programming Foundations: Design Patterns
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
The iterator pattern as language feature
课程: Programming Foundations: Design Patterns
The iterator pattern as language feature
- [Instructor] The iterator pattern is one of those patterns that is so useful it's become built-in to languages as language features. Languages provide built-in iterators as we saw with Java collections and they use iterators in language statements too. These statements hide the iterator pattern and it's iterators behind the scenes and make it easy to iterate through collections of values. Java, Python and JavaScript all have statements that use the iterator pattern behind the scenes. Java's enhanced for statement is designed for iteration through collections and arrays. So this code will work whether animals is an ArrayList of animal objects or an array of animal objects. Python's for/in statement can be used with any iterable aggregate object such as string, list and tuple and JavaScript's for/of statement can be used with strings, arrays, maps and sets. All of which are iterable objects meaning there are iterators…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
-
(已锁定)
Encapsulating iteration1 分钟 44 秒
-
(已锁定)
Understanding the Iterator pattern2 分钟 28 秒
-
(已锁定)
Using the Iterator pattern3 分钟 36 秒
-
(已锁定)
Using built-in iterators1 分钟 19 秒
-
(已锁定)
The single responsibility principle1 分钟 20 秒
-
(已锁定)
The iterator pattern as language feature1 分钟 30 秒
-
(已锁定)
Challenge: The Iterator pattern57 秒
-
(已锁定)
Solution: The Iterator pattern36 秒
-
(已锁定)
-
-