From: Sean O'Halpin Date: 2007-04-06T23:12:51+09:00 Subject: Re: the most useful code i've written in a while On 4/6/07, Robert Klemme wrote: > On 06.04.2007 02:54, Trans wrote: > > > > On Apr 5, 5:34 pm, "Ara.T.Howard" wrote: > >> harp:~ > cat errno > >> #! /usr/bin/env ruby > >> 256.times do |errno| > >> puts "#{ errno } => #{ SystemCallError.new(errno).inspect }" > >> end > > > > Nice. > > > > Hmm... How about an inheritance tree too? > > robert@fussel /cygdrive/c/Temp > $ ruby tr.rb > tree.txt > > robert@fussel /cygdrive/c/Temp > $ wc -l tree.txt > 897 tree.txt > > robert@fussel /cygdrive/c/Temp > $ cat tr.rb > require 'pp' > ins = lambda {|h,k| h[k] = Hash.new(&ins)} > tree = Hash.new(&ins) > ObjectSpace.each_object(Class) {|cl| tree[cl.superclass][cl] = tree[cl]} > pp tree Nice! Small refinement for tree of Exceptions: tree[cl.superclass][cl] = tree[cl] if cl <= Exception Regards, Sean