From: Gavin Sinclair Date: 2003-12-10T21:27:31+09:00 Subject: Re: Request for comments (longish) On Wednesday, December 10, 2003, 10:33:44 PM, David wrote: > This is a place where you could, conceivably, use my favorite > 1.8.0-and-greater "trick": > class Operation > @derivatives = Hash.new {|k,v| raise "No class Operation::#{v}" } > # ... > def Operation.[](name) > @derivatives[name] > end Love that trick. Here's how I initialized a hash recently. (The algorithm called for setting some initial values and then removing things as necessary.) # players == %w{Sam Min ...} result = Hash.new { |h,k| h[k] = [:white, :black] } result.values_at(*players) End result of that: result == { "Sam" => [:white, :black], "Min" => [:white, :black], ... } Oooooh... delicious. Gavin