CSC/ECE 517 Fall 2012/ch1 1w58 am

From Expertiza_Wiki
Jump to navigation Jump to search

Ruby Blocks, Iterators, Functional Idioms

This wiki-page serves as a knowledge source for understanding Ruby Blocks, Iterators, Functional Idioms.

Introduction

Ruby has simplified the way programmers use loops and iterators. Ruby helps programmers to use DRY principle effectively by using blocks and defining iterators over collections. This helps in minimizing the development work that programmers often find in any other O-O style programming language. In ruby, these iterators, blocks and functional idioms are explained as:

Iterators are Collection defined methods that helps to iterate over all the elements present in a Collection. Ruby Collections are basically objects that store a group of data members of various types. Examples of Collection are arrays, hashes etc. A block consists of chunks of codes with a name assigned to it enclosed withing braces. For example,

my_block { puts "Hello World" }

Functional idioms are ... (please feel free to add about functional idioms here and become the author of it :) )

Topical References

Further Reading