Index: struct.c =================================================================== --- struct.c (revision 38740) +++ struct.c (working copy) @@ -283,9 +283,10 @@ /* * call-seq: - * Struct.new( [aString] [, aSym]+> ) -> StructClass - * StructClass.new(arg, ...) -> obj - * StructClass[arg, ...] -> obj + * Struct.new( [aString] [, aSym]+> ) -> StructClass + * Struct.new( [aString] [, aSym]+> ) {|| block } -> StructClass + * StructClass.new(arg, ...) -> obj + * StructClass[arg, ...] -> obj * * Creates a new class, named by aString, containing accessor * methods for the given symbols. If the name aString is @@ -296,6 +297,16 @@ * letter. Assigning a structure class to a constant effectively gives * the class the name of the constant. * + * If a block is given, it will be evaluated in the context of + * StructClass. + * + * Customer = Struct.new(:name, :address) do + * def greeting + * "Hello #{name}!" + * end + * end + * Customer.new("Dave", "123 Main").greeting # => "Hello Dave!" + * * Struct::new returns a new Class object, * which can then be used to create specific instances of the new * structure. The number of actual parameters must be