From: matz@... (Yukihiro Matsumoto) Date: 2000-04-08T23:55:18+09:00 Subject: [ruby-talk:02399] Re: Iterator into array Hi, In message "[ruby-talk:02384] Re: Iterator into array" on 00/04/07, Dave Thomas writes: |Do you ever sleep ;-) Sometimes. I slept all day long today. I've got a cold. Don't stay up too late, kids. ;-) | def fibUpTo(max) | i1, i2 = 1, 1 | while i1 <= max | yield i1 | i1, i2 = i2, i1+i2 | end | end | | fibUpTo(20) -> [1,1,2,3,5,8,13] But fibUpTo() has its return value, which happens to be meaningless for this method, other than yielded values. So it may be better that: fibUpTo(20) -> nil/[1,1,2,3,5,8,13] In addition, not all blocks are used for iteration. For example, how do you think the following should be documented? [4,2,4,5].sort -> [2,4,4,5]/[[4, 4],[4, 5],[2, 4],[4, 2]]? matz.