Join Kevin Skoglund for an in-depth discussion in this video Iterators, part of Ruby Essential Training.
In this movie we are going to take a look at the Ruby Control Structure for iterators.…Now iterators work a lot like loops which we just saw in the last movie.…The difference is that instead of just looping, waiting for something to happen…for us to take control and to either break out of it or to do something else,…instead with an iterator we are going to traverse a fixed set of data.…So we can kind of know where the starting point and the ending point is.…We basically want to say for each one of these things do this process, do this loop, right.…So we are going to do a code block once for each item in a set of data.…
Now we can accomplish that with loops.…For example here is a While loop.…Essentially what this while loop is doing is just outputting Hello five times.…Before trying to do that, there is a simpler way to do it using the Ruby syntax,…which is just to say 5.times do and then our code block.…That's a lot easier. It is a lot cleaner.…It is easier to see what we are trying to do and we have to write less code in the process.…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
Q: You mention e-texteditor.com as a place to get a Windows "sister" version of TextMate. However, e-texteditor.com looks like a Chinese auto website. Are there any other alternatives?
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.