Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Posts tagged ‘ruby blocks’

Example using ruby blocks, lambda and Proc

What really distinguishes ruby from other languages is the syntatic sugar of blocks. For example, blocks really come in handy when iterating thru a collection. The example: (1..10).collect{|i| i*i} => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] But how does the collect method work? Let’s define an array containing all the prime [...]