Josselin wrote: >>> I have an array myArray = ["22", "31", "56", "89", "47"] >>> >>> I would like to produce a string like : "22#31#56#89>47<" where the >>> last item must be : >last_item< Here you say that you want the second to last item to have no # after it, > > I should get "22#>31<", the # must come after each item excepted the > last.. but here you say you want a # after it. If you want no # sign, then Josselin's solution works. If you want a # sign, just push that last item back on the array and join it with # myArray = ["22", "31", "56", "89", "47"] myArray2 = ["22", "47"] myArray3 = ["47"] arrays = [myArray, myArray2, myArray3] arrays.each{|array| puts array.push('>' + array.pop.to_s + '<').join('#')}