Jim Weirich wrote:
> On Thursday 11 August 2005 11:41 pm, dave.burt / gmail.com wrote:
>> If a Strategy is a single function, I'd probably do it more like this,
>> though:
> [... proc based solution elided ...]
>
> Agreed, unless the strategy object requires state.  E.g.
> ...
>  class HourlyStrategy
>    def initialize(hourly_rate, timecards)
> ...

You can put state in procs, too - using local variables rather than instance 
variables. (I'm sorry, I'm learning Haskell.)

Of course, the following way is more stupid than Jim's way in the parent 
post, which allows not only state, but also private helper methods.

HourlyStrategy = proc do |hourly_rate, timecards|
  proc do
    timecards.inject(0.0) { |s, tc| s + tc.calculate_pay(hourly_rate) }
  end
end

I was going to say that this is more stupid than Jim's way, and his is 
definitely more Java-ish, but I kind of like the look of that.

Cheers,
Dave