From: George Ogata Date: 2005-11-27T22:52:28+09:00 Subject: Re: recursion "cyberco" writes: > Thanks! That is certaily a elegant solution, but I wonder what the > logic behind it is. I can't find any documentation on this usage of > ranges, any pointers? Here's how you get there: ('aaa'..'zzz').to_a is clearly a call to Range#to_a. * `ri Range` tells you that Range gets #to_a from Enumerable. * `ri Enumerable#to_a` tells you that it returns the elements yielded by a call to #each. (Oh wait, it doesn't. It should... . Really, it's no secret that all of Enumerable's methods are defined in terms of #each, but I can't find it anywhere in the rdoc comments.) * `ri Range#each` tells you that the elements yielded come from successive calls to each element's #succ method, starting with the start object ('aaa' in this case). * `ri String#succ` tells you that 'aaa'.succ will return 'aab' (and so on). * Profit! (Er... QED.) HTH, George.