From: Mario Antonetti Date: 2010-03-25T13:38:07+09:00 Subject: Re: Arrays --0016e6db29b58f709d0482989cb0 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Mar 24, 2010 at 10:27 PM, Rajkumar Surabhi wrote: > Hi all, > > i have an array contains no of elements. i want to concatinate 91 before > every elemnt of array. example > > i have > A= [234,456,raju] like this > i want the out put arry tobe A=[91234,91456,91raju] like thissss > > i want to add 91 before every element > > how to do this > -- > Posted via http://www.ruby-forum.com/. > > the assignment of the variable should look more like this: ------------------------------------------------------------- a = ["234","456","raju"] ------------------------------------------------------------- because otherwise raju is a variable, which wouldn't allow you to append 91 to the beginning of it. Try this then: -------------------------------------------------------- array.collect! do |element| "91" + element.to_s end -------------------------------------------------------- Mario --0016e6db29b58f709d0482989cb0--