Posted tagged ‘meta-programming’

meta-initializers

March 12, 2008

While reading something of why’s on meta-programming, and looking at some of his example code

class MailTruck
  attr_accessor :driver, :route
  def initialize( driver, route )
    @driver, @route = driver, route
  end
end


I thought to myself “why don’t we have something as DRY as attr_accessor for meta-programming the initialize method? Why not something like

class MailTruck
  attr_accessor :driver, :route
  initializer :driver, :route 
end

?”
In other words, why write “driver, route” three times?

A project for a rainy day…