From: Colin Bartlett Date: 2010-04-03T20:50:32+09:00 Subject: Re: combined ranges... On Fri, Apr 2, 2010 at 11:33 PM, Roger Pack wrote: > David Springer wrote: >> Will this work: >> [1..20,30..46].each{|r| r.each {|n| p n}} > > Yeah that works. > I guess if I need individual values in there (like 25) I can do > [1..20, 25..25, 30..46].each{|r| r.each {|n| p n}} Given the solutions proposed, in suggesting this I have a feeling I may well be missing something, but since I might learn something: why not write a method (and maybe add it to Array) like: def each_element_or_range_element( arr ) arr.each do |er| if er.kind_of?( Range ) then er.each { |e| yield e } else yield er end end end aa = [ 1..2, 355, 3..4, 113, 2.5 , 3.5..5.5 ] each_element_or_range_element(aa) { |e| print " #{e}" } 1 2 355 3 4 113 2.5 TypeError: can't iterate from Float