From: mirian@... (Mirian Crzig Lennox) Date: 2001-06-11T03:15:54+09:00 Subject: [ruby-talk:16392] yield to list? So, suppose I have a function like: def numstrings x, y for i = x..y yield i.to_s end What I'd like to be able to do it have all the yields from that function end up in a list or array. Of course, I could do this: arr = [] numstrings(22, 29) { |x| arr.push(x) } arr ==> [ "22", "23", "24", "25", "26", "27", "28", "29" ] But that involves a loop and pushes, and seems inefficient. Also, it seems that Ruby probably could build this list internally much more efficiently. So, what would be nice would be there were some way to put yield in a context in which all the yields could be automatically collected into a list, e.g. arr = (numstrings(22, 29)).to_list but without having to explictly write a loop and push. --Mirian