From: Graham Foster Date: 2004-09-24T04:09:32+09:00 Subject: Re: Newbie: Case statement > Yup, you can use this as a case that checks all options: > > def greedy_case(obj, cases) > cases.find_all do |condition, action| > condition === obj > end.inject(Hash.new) do |hash, (condition, action)| > hash[condition] = action.call; hash > end > end OK - Does this do the following (roughly) - passes the input variable (x) and a hash of ranges and pointers to functions (C speak) - No idea what end.inject means, but the effect is to iterate through the hash of "ranges" (or presumably eny condition), and for each match (determined by === must look this up) execute the inline function (block). - What is the last hash for? Roughly right? What a devious mind you have Florian. Graham