Ruby on Rails extends many of the Ruby types with interesting and often useful methods. The to_sentence method on arrays returns the values in an array separated by commas with a conjunction between the last two. There are two options. :connector provides the conjunction with ‘and’ being the default. :skip_last_comma is a boolean that determines whether or not the last comma is displayed and the default is true.
favorite_fruit = ['apples', 'oranges', 'grapes'] puts "My favorite fruits are...