# Array.new returns nil

**URL:** <https://rubytalk.org/t/array-new-returns-nil/5564>\
**Category:** ruby-talk\
**Created:** [9 April 2003 09:38 UTC](https://rubytalk.org/t/array-new-returns-nil/5564 "2003-04-09T09:38:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Han\_Holl3](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@Han\_Holl3](https://rubytalk.org/u/Han_Holl3)\
**Post date:** [9 April 2003 09:38 UTC](https://rubytalk.org/t/array-new-returns-nil/5564/1 "2003-04-09T09:38:26Z")

</div>

Greetings,

Is there anything known about a possible Ruby-1.6.8 bug, where Array.new  
starts returning nil ?  
I have a class that starts like this:

class Awkstack \< Array  
@@sharedtext = nil  
attr\_reader :lastrub

def initialize(left)  
@left = left  
@CurrentDictStack = Array.new  
if ! @CurrentDictStack  
count = 0  
ObjectSpace.each\_object { count += 1 }  
debug "#{count} objects"  
ObjectSpace.garbage\_collect  
sleep 5  
count = 0  
ObjectSpace.each\_object { count += 1 }  
debug “#{count} objects”  
@CurrentDictStack = Array.new  
exit unless @CurrentDictStack  
end  
debug "init: #{object\_id} #{@CurrentDictStack.object\_id}"  
end

# end-of-code

After a certain amount of processing this process dies, first indicating  
about 93000 objects, 5 seconds later some 60000. The process is about 11 Mb  
in size. Different machines, differnet libc’s and different Linux kernels.  
Ruby 1.6.8 out of the box, no extensions of my own, only extension not in  
ruby core is REXML-2.5.7.

It runs fine under 1.8.0, so it’s not a project stopper, but I’m of course  
curious.

Cheers,

Han Holl

---

<div class="post-metadata">

**Author:** ![Simon\_Strandgaard](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Simon\_Strandgaard](https://rubytalk.org/u/Simon_Strandgaard)\
**Post date:** [9 April 2003 10:38 UTC](https://rubytalk.org/t/array-new-returns-nil/5564/2 "2003-04-09T10:38:58Z")

</div>

I see you are inheiriting from Array, but you don’t call super.  
Aren’t you suppose to call super here ???

> **···**
>
> On Wed, 09 Apr 2003 03:23:46 +0000, Han Holl wrote:
> 
> > class Awkstack \< Array  
> > @@sharedtext = nil  
> > attr\_reader :lastrub
> > 
> > def initialize(left)  
> > @left = left  
> > @CurrentDictStack = Array.new  
> > if ! @CurrentDictStack  
> > count = 0  
> > ObjectSpace.each\_object { count += 1 }  
> > debug “#{count} objects”  
> > ObjectSpace.garbage\_collect  
> > sleep 5  
> > count = 0  
> > ObjectSpace.each\_object { count += 1 }  
> > debug “#{count} objects”  
> > @CurrentDictStack = Array.new  
> > exit unless @CurrentDictStack  
> > end  
> > debug “init: #{object\_id} #{@CurrentDictStack.object\_id}”  
> > end
> > 
> > # end-of-code
> 
> –  
> Simon Strandgaard

---

<div class="post-metadata">

**Author:** ![Han\_Holl3](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@Han\_Holl3](https://rubytalk.org/u/Han_Holl3)\
**Post date:** [9 April 2003 14:19 UTC](https://rubytalk.org/t/array-new-returns-nil/5564/3 "2003-04-09T14:19:41Z")

</div>

“Simon Strandgaard” [0bz63fz3m1qt3001@sneakemail.com](mailto:0bz63fz3m1qt3001@sneakemail.com) wrote in message news:[pan.2003.04.09.10.26.26.885195@sneakemail.com](mailto:pan.2003.04.09.10.26.26.885195@sneakemail.com)…

> **···**
>
> > On Wed, 09 Apr 2003 03:23:46 +0000, Han Holl wrote:
> > 
> > >
> 
> > I see you are inheiriting from Array, but you don’t call super.  
> > Aren’t you suppose to call super here ???
> 
> I think ruby provides one if you omit it. Anyway I tried with  
> super(0), and it made no difference.  
> Still dies in 1.6.8 and runs fine on 1.8.0
> 
> Thanke for trying, though.
> 
> Cheers,
> 
> Han Holl
