From: Adam Akhtar Date: 2008-02-10T21:38:22+09:00 Subject: Re: Array Practice ....to doing the opposite. Although there is already a method call to flatten arrays i thought since i created an unflatten one above i should have go at flattening. It takes a nested array and then returns a flattened version def flattenlist nestedlist flatlist = [] return flatlist if nestedlist.empty? if (nestedlist.first.is_a?(Array)) flatlist.push nestedlist.first.shift nestedlist.delete_at(0) if (nestedlist.first.empty?) else #not array so just add flatlist.push nestedlist.shift end flatlist = flatlist + flattenlist(nestedlist) flatlist end What do you guys/girls think? give me your hints and ill go away and improve it! I wasnt so happy with this part if (nestedlist.first.is_a?(Array)) flatlist.push nestedlist.first.shift nestedlist.delete_at(0) if (nestedlist.first.empty?) I have a feeling theres a delete method that after deleting the last element in an empty array will delete the array itself. -- Posted via http://www.ruby-forum.com/.