Exercises, examples and other material relating to training module R112. This topic is presented on public courses Learning to program in Ruby
, Ruby Programming
|Articles and tips on this subject||updated|
|4680||Processing data line by line - iterator in Ruby with yield|
If you have a big file / flow of data in Ruby, you probably don't want to read it all in to an array before you do any processing. Not only would that mean you couldn't produce any output until you have read all the data, but it would also make for a big process - probably inefficient, possibly doing ...
|3156||Splitting data reading code from data processing code - Ruby|
An iterator (a.k.a. generator in Python) is a function which returns its results as it calculates them, rather than building them up into a larger structure to return all at once when the function is completed. So where you have a big flow of incoming data, you can handle it as it arrives rather than ...
|2979||Ruby - yield; parallel routines|
When you call a function / method in your program, you expect it to run to completion before returning control to you, passing back a result. For example, you might call a method to read a series of objects and store them into an array ... and then you could take that array of objects and, iterating ...
Examples from our training material
|faucet|| a series of methods in a production line|
|feeder|| yield and iterator - practical example|
|lynes.rb|| How to write and use an iterator|
|papo|| yield - calling back to a code block|
|tap|| Reading a file in parallel to processing|
|ytb.rb|| Your own data iterator|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Parallel assigments. Yield.
Threads, the thread scheduler and thread exceptions.
Thread critical, Mutex and Condition variables.
Spawning processes and controlling children.
Allowing your children to go independent.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.