From: Brian Candler Date: 2003-03-16T08:00:07+09:00 Subject: Re: vcard 0.1 - how to do return values that can have 0, 1, or >1 cardinality On Sun, Mar 16, 2003 at 07:21:26AM +0900, Sam Roberts wrote: > I also noticed that Enumrable.find_all() always returns an array, its > just sometimes it has a size of zero. > > So, I've been drifting towards that. > > Currently, the _all() APIs return an array, or nil, so if the return > value is true, then there is guaranteed to be at least one member, but > I'm starting to feel there's a mismatch between this way, and the Ruby > Way, so I might just always return an array for the _all() functions. > I'm still thinking about it. > > What to other people do? I don't have experience with enough APIs to > know. FWIW, in the DBI library which I have been using quite a lot recently: dbh.select_one returns nil or a row dbh.select_all returns an array of rows, or [] if no rows were found [] can be convenient because you can do 'each' on the result without having to test for nil first. Regards, Brian.