Flowdock
method

to_sentence

Importance_3
v3.0.5 - Show latest stable - 3 notes - 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
2 thanks

example

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

April 1, 2014
1 thank

Sometimes, you need the "Oxford comma"

Re: Gramatical error

http://imgur.com/fycHx

We invited the strippers, JFK, and Stalin.

versus the appositive phrase:

We invited the strippers, JFK and Stalin.

(Really, you need to see the comic to appreciate the difference.)

April 1, 2014
0 thanks

Grammatical error

Hi - not sure where I would submit this so just putting here. My apologies if not in the right place.

default: “, and ” - this is grammatically wrong. There should be no comma with the last and.

Example:

[‘one’, ‘two’, ‘three’].to_sentence

should give: “one, two and three”

There is no ‘ .… , and ’ which is considered grammatically incorrect I feel. The ‘and’ does it’s job in the English language quite well by joining the two words it’s in between.

Thank you.