Aleksi Niemel? <aleksi.niemela / cinnober.com> writes:

> Then code 
> 
> >        def AtExit.runHandlers
> >          @@thingsToRun.reverse_each { |thing| thing.call }
> >        end
> 
> works perfectly but wouldn't work when written as

which is why I wrote it that way

>   def AtExit.runHandlers
>     @@names.each {|name, thingIndex| @@thingsToRun[thingIndex].call }
>   end
> 
> as there's no @@thingsToRun[1].

rather than that way!


However, you're right - there is a bug in delete. If you delete two
things, and the second has an index greater tahn the first, then it
isn't deleted properly.

The fix is left as an exercise for the reader.


Dave