Re: Unique constraints
[prev]
[thread]
[next]
[Date index for 2005/03/04]
On Fri, 4 Mar 2005 16:08:20 +0000, Tony Bowden <tony-cdbitalk@xxxxx.xxx> wrote:
> On Fri, Mar 04, 2005 at 07:49:04AM -0500, Cees Hek wrote:
> > Will search not return an iterator in this case and hence always be
> > true? shouldn't that be:
> > return not $self->search(foo => $value)->first;
>
> An iterator in numeric context overloads to the count, so this should be
> OK.
Interesting. Is that documented anywhere?
> Your way could fall down if the first thing back stringified to a false
> value.
Good point, so how about this for clarity:
return not $self->search(foo => $value)->count;
Thanks for clarifying that.
--
Cees Hek