You can turn arrays into sentences!
There's a neat little method
Array#to_sentence that turns your array into a string in sentence format.
It's pretty self-explanatory, so here are some examples:
superheroes = ["Spider-Man", "Batman", "Iron man", "Wonder woman"] superheroes.to_sentence => "Spider-Man, Batman, Iron man, and Wonder woman" superheroes.to_sentence( words_connector: " or ", last_word_connector: " or maybe even " ) => "Spider-Man or Batman or Iron man or maybe even Wonder woman"
With slight configuration, you can even have this work in different locales. Check it out in the docs!Tweet