CSC/ECE 517 Spring 2015/ch1a 9 RA

From Expertiza_Wiki
Revision as of 18:47, 1 February 2015 by Rhjoshi (talk | contribs)
Jump to navigation Jump to search

Lazy Enumerators

Background

In Ruby 1.8 and Ruby 1.9 the problem with enumeration that generate infinite sequences is that we have to write special, non-greedy, versions of methods. But, if you’re using Ruby 2.0 or later, you have this support built in. If you call Enumerator#lazy on any Ruby enumerator, you get back an instance of class Enumerator::Lazy. Many basic class like Array and Hash has lazy method through Enumerator class.