2007/9/4, Paul Brannan <pbrannan / atdesk.com>:
> On Tue, Sep 04, 2007 at 07:01:15PM +0900, Paul Butcher wrote:
> > > Customer = Struct.new(:name, :address) do
> > >   def to_s
> > >     "Customer called '#{name}' living at '#{address}'"
> > >   end
> > > end
> >
> > > class Customer < Struct.new(:name, :address)
> > >   def to_s
> > >     "Customer called '#{name}' living at '#{address}'"
> > >   end
> > > end
>
> Why not reopen the class?
>
>     Customer = Struct.new(:name, :address)
>     class Customer
>       def to_s
>         "Customer called '#{name}' living at '#{address}'"
>       end
>     end

Why should I reopen a class if I can have everything with the block?

Customer = Struct.new :name, :address do
  def to_s
    "Customer called '#{name}' living at '#{address}'"
  end
end

Kind regards

robert