all samples with I18n.locale = :es
brew code, a lot of possible errors
def join_items(collection)
return collection.first if collection.size == 1
all_but_last = collection.take(collection.size - 1)
[all_but_last.join(', '), collection.last].join(' y ')
end
join_items(%w(foo bar baz))
$=> "foo, bar y baz"
using to_sentence
from ActiveSupport
%w(foo bar baz).to_sentence
$=> "foo, bar, y baz"