Array to String with commas and "and" before the last elemen

Ruby code posted by Hallison Batista
created at 31 Jul 04:21, updated at 31 Jul 04:21

Edit | Back
1
2
3
array = ["one","two","three","four","five"]
join  = array[0..-2].join(', ') + " and " + array[-1].to_s + " are numbers that belongs to the array of integers."
puts join
170 Bytes in 2 ms with coderay