On Tue, 10 Aug 2004, Martin DeMello wrote:

> Robert Klemme <bob.news / gmx.net> wrote:
>>
>> Hm, sounds to me like it was not general enough to include it in
>> Enumerable.  Before I see that method I'd prefer to have size and empty?
>> in Enumerable.  Just my 0.02 EUR...
>
> Can empty? be reliably implemented in terms of each for every
> enumerable? I can't think of an obvious problem with it, but that
> doesn't mean there isn't one.

def empty?
   each do |element|
     return false
   end
   true
end

def size
   inject(0) {|n,e| n+=1}
end


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand

The universe is absolutely plastered with the dashed lines exactly one
space long.