Created
July 30, 2008 01:15
-
-
Save hallison/3205 to your computer and use it in GitHub Desktop.
Array to String with commas and "and" before the last element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# "one, two, three, four and five are numbers that belongs to the array of integers." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment