From: Farrel Lifson Date: 2007-05-25T19:34:59+09:00 Subject: Re: Replacement idiom for "list_or_nil.to_a"? On 25/05/07, Rich Morin wrote: > I suppose I could define my own to_a method for nil, > but that seems a bit questionable, as well. So, is > there a Better Way To Do It? If you're going to get a list or nil then I find it nice to wrap it in the Kernel#Array() method. It will convert a nil to a an empty array but will leave an array untouched: irb(main):001:0> Array(nil) => [] irb(main):002:0> Array([1,2,3]) => [1, 2, 3] Farrel