From: Olivier Renaud Date: 2007-02-25T03:17:17+09:00 Subject: Re: using step backward ? Le samedi 24 f�vrier 2007 19:00, Josselin a �crit�: > 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< > > case 1 item : ["22"] => ">22<" > case 2 items : ["22", "31"] => "22#>31<" > .. > case n items : ["22", "31", "56", .........., "89", "47"] => > "22#31#56#...........#89>47<" > > as it's always the last items getting special treatment I thought > starting with " >"+myArray.last +"< " then > using 1.step(myArray.length-1, -1) do {..... put # after item } and > concatenate if myArray.length > 1 > but I cannot get it right... I cannot get simple > > tfyh > > joss You may want to use Array#slice and Array#join to do that. And, as you said, make a special treatment for the last element. -- Olivier Renaud