--0016364ed738995da104b3f944e1 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Dec 13, 2011 at 4:08 AM, Adit Cahya Ramadhan Adit < matematika.adit / gmail.com> wrote: > I'm thinking to translate string to an array like this: > "aaabbccccdadd" [ [a, 3], [b, 2], [c, 4], [d, 1], [a, 1], [d, 2] ] > > this is my code: > > ary ] > "aaabbccccdadd".scan(/((.)\2*)/){ |a,b| ary << [b, a.size] } > > ary # [["a", 3], ["b", 2], ["c", 4], ["d", 1], ["a", 1], ["d", 2]] > > But, I wonder if there are more effective or beautiful solution than > this. > How do you think? > > -- > Posted via http://www.ruby-forum.com/. > > Anyone else look at String#squeeze and get sad that it didn't take a block? One day... one day I will use you, String#squeeze -.^ --0016364ed738995da104b3f944e1--