From: Gary Wright Date: 2008-03-07T01:27:13+09:00 Subject: Re: duplicating characters in a string On Mar 6, 2008, at 11:12 AM, Adam Akhtar wrote: > If i have a string "abc" and want to make it like this "aabbcc", > how do > i go about it? > > I thought convert it into an array and then use string.map{|x| x << x} > > though i havnt tested that yet. Is there a better way or a string > method > that saves me from having to convert it into an array? Ask 10 Ruby programmers this question and I'm sure you'll get 11 different answers. If your definition of 'best' is 'fastest' you'll simply have to code and benchmark a couple of solutions. Here is one way to do it: >> a = "abc" => "abc" >> (b = a.split(//)).zip(b).join => "aabbcc" Gary Wright