# Array to string

**URL:** <https://www.ruby-forum.com/t/array-to-string/162010>\
**Category:** Ruby\
**Created:** [March 4, 2009, 8:57pm UTC](https://www.ruby-forum.com/t/array-to-string/162010 "2009-03-04T20:57:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 4, 2009, 8:57pm UTC](https://www.ruby-forum.com/t/array-to-string/162010/1 "2009-03-04T20:57:52Z")

</div>

If I have a array: a = [“a”, “a”, “b”, “b”, “c”]

How can I get a string: “a, a, b, b, c”

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 4, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/array-to-string/162010/2 "2009-03-04T21:03:16Z")

</div>

Fresh M. schrieb:

> If I have a array: a = [“a”, “a”, “b”, “b”, “c”]
> 
> How can I get a string: “a, a, b, b, c”

[“a”, “a”, “b”, “b”, “c”].join(’, ')

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 4, 2009, 9:05pm UTC](https://www.ruby-forum.com/t/array-to-string/162010/3 "2009-03-04T21:05:38Z")

</div>

On [Thu, 05.03.2009 04:56], Fresh M. wrote:

> If I have a array: a = [“a”, “a”, “b”, “b”, “c”]
> 
> How can I get a string: “a, a, b, b, c”

By using Array#join

> > > irb  
> > > a = [“a”, “a”, “b”, “b”, “c”]  
> > > =\> [“a”, “a”, “b”, “b”, “c”]
> 
> > a.join(", ")  
> > =\> “a, a, b, b, c”
