From: Benjohn Barnes Date: 2006-04-01T19:34:39+09:00 Subject: Re: (Static) Constructors/Destructors in Ruby --Apple-Mail-14-224241553 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On 1 Apr 2006, at 11:25, Benjohn Barnes wrote: > :) It's such a fresh beautiful day outside... and here I am talking > tech, when spring is springing :) It really is! > Ok, in Ruby, each of those resources could easily be turned in to a > method that will run a block. What you want to be able to do then, > is easily compose those methods in to one, and have that run > something within the context of resources being available? > > Something along the lines of (unchecked code warning!)...? > > def run_with_resources(*resources, &block) > if resources == [] > yield > else > send(resources.slice(0)) {run_with_resources(*resources, &block)} That was supposed to be: send(resources.slice!(0)) {run_with_resources(*resources, &block)} The ! after slice is vital! --Apple-Mail-14-224241553--