Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 467 Bytes

combining_an_array_into_one_string.md

File metadata and controls

26 lines (18 loc) · 467 Bytes

How to combine an array into one string

Join returns a string created by converting each element of the array to a string, separated by a separator string, if given

Examples

Without separator:

[1, 2, 3].join
# => "123"

With single character separator:

["oranges", "apples", "bananas"].join ';'
# => "oranges;apples;bananas"

With a string separator:

["Alice", "Bob", "Carol"].join ", "
# => "Alice, Bob, Carol"