From: James Edward Gray II Date: 2007-09-04T21:13:30+09:00 Subject: Re: Struct is cleverer than the documentation claims On Sep 4, 2007, at 5:01 AM, Paul Butcher wrote: > So, both of the following achieve broadly the same effect: > >> 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 > > Which leads to the question, what *are* the differences, and should I > prefer one approach over the other? > > Thanks in advance for any light you can cast on this! I too feel the block is better. You can occasionally run into issues with the base class form. For example, when Rails does it's reloading magic on a file containing such a construct you will receive an error. James Edward Gray II