CSC/ECE 517 Fall 2012/ch1 1w58 am: Difference between revisions
Line 7: | Line 7: | ||
= Introduction = | = 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" } | |||
= Topical References = | = Topical References = |
Revision as of 05:42, 30 September 2012
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" }