Simon Vandemoortele wrote:
> I thought I might share this little piece of code that generates a
> 'lstree'-like output for class-hierarchy:

I love it!

I know it's a bit anally retentive :-) ... but I prefer references like this in alphabetical order,
so I added a line:

> def lstree(root)
>   # get children of root
>   children = Hash.new()
>   ObjectSpace.each_object(Class) do |aClass| 
>     if (root != aClass && aClass.ancestors.include?(root))
>       children[aClass.superclass] = Array.new() if children[aClass.superclass] == nil
>       children[aClass.superclass].push(aClass)
>     end
>   end
> 
>   # print nice ascii class inheritance tree
>   recursePrint = proc {|current_root,prefixString|
>     puts(prefixString+"- "+current_root.to_s)
>     if children[current_root] != nil
        children[current_root].sort! {|a, b| a.to_s <=> b.to_s}  # <---- THIS ONE
>       children[current_root].each do |child|
>           recursePrint.call(child,prefixString.tr('`',' ') + "    "+(child == children[current_root].last ? "`":"|"))
>       end
>     end
>   }
>
>  recursePrint.call(root,"")
> end

-------------------------------------
I have always imagined that Paradise will be
a kind of library. - Jorge Luis Borges.