--Apple-Mail-15-274981736
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset-ASCII;
	format­´wed


On 1 Apr 2006, at 21:32, Cameron McBride wrote:

> .join(', ').sub(/, (\S+)$/,' and \1')

:) Groovy - and it works for the edge cases too...

irb(main):033:0> a,2,3]
[1, 2, 3]
irb(main):034:0> a.join(', ').sub(/, (\S+)$/,' and \1')
"1, 2 and 3"
irb(main):035:0> a,2]
[1, 2]
irb(main):036:0> a.join(', ').sub(/, (\S+)$/,' and \1')
"1 and 2"
irb(main):037:0> a]
[1]
irb(main):038:0> a.join(', ').sub(/, (\S+)$/,' and \1')
"1"
irb(main):039:0> a
[]
irb(main):040:0> a.join(', ').sub(/, (\S+)$/,' and \1')
""

Thanks.

It still seems like a nice one to have in the standard, to me.

Cheers,
	B
--Apple-Mail-15-274981736--