func comma_quibbling(words) { '{' + ([words.first(-1).join(', ')]-[''] + [words.last] -> join(' and ')) + '}' } [<>, <ABC>, <ABC DEF>, <ABC DEF G H>].each { |w| say comma_quibbling(w) }
{} {ABC} {ABC and DEF} {ABC, DEF, G and H}
Last updated 1 year ago