Enumerable#zip
is good at making pairs. In a way that is intuitive and easy to grasp.
#zip
is taking a block. Guess what happens.
(1..4).zip(1..4) {|a,b| a*b }
nil
. It shows up that zip is commonly being used for multiway each! Thats a broken metaphor, which give people bad habits. See [] for discussion.
I propose that zip
concatenates and returns the result of the supplied block.
(4..6).zip(10..12) {|a,b| a*b } #=> [40, 55, 72] %w(a b c).zip(1..9) {|i| i.reverse } #=> [[1, 'a'], [2, 'b'], [3, 'c']]
callcc
/enumerator
instead of this bad habbit.
Back to RCRchive.
RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog