From: Robert Klemme Date: 2010-04-04T19:10:07+09:00 Subject: Re: combined ranges... On 04/03/2010 05:47 PM, Colin Bartlett wrote: > I also like Robert Klemme's idea of having a level parameter, > so if Robert is agreeable - and from his Ruby-talk posts he seems to be > a very agreeable person! - maybe include levels, maybe renamed depth? > (I've thought of using level in a more general Find module, and > eventually decided depth was a better word for the concept. I can't > remember why, but I'm sure there must have been very good reasons!) Thanks! I think you're right: "depth" is a better name than "level". It's probably because "depth" hints at "descending into the collection" while "level" rather sounds like "ascending". > A question: should the depth/levels test be levels > 1 or > 0? > Using [ 2..2 ] and "levels > 1": > levels param: 0 #=> 2..2; 1 #=> 2..2; 2 #=> 2; > Using [ 2..2 ] and "levels > 0": > levels param: 0 #=> 2..2; 1 #=> 2; 2 #=> 2; > It seems (maybe?) more logical to have depth/levels arguments: > 0 means don't do any recursive expansion of each; > 1 means do some recursive expansion of each; It's probably a matter of taste. I used "levels = 1" to indicate that we step down one level (i.e. into the collection) - that would be the same as what #each does out of the box. "levels = 2" means, go one level further. Consequently "level = 0" in my model would mean, do not step down at all. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/