Flowdock
method

to_sentence

Importance_2
v3.0.7 - Show latest stable - 1 note - Class: Array
to_sentence(options = {}) public

Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options:

  • :words_connector - The sign or word used to join the elements in arrays with two or more elements (default: ", ")
  • :two_words_connector - The sign or word used to join the elements in arrays with two elements (default: " and ")
  • :last_word_connector - The sign or word used to join the last element in arrays with three or more elements (default: ", and ")
Show source
Register or log in to add new notes.
December 17, 2011
1 thank

example

[‘one’,‘two’,‘three’].to_sentence # => “one, two, and three”