Hi,

In message "Re: subclassing Structs"
    on 03/08/14, Eugene Scripnik <Eugene.Scripnik / itgrp.net> writes:

|My example didn't show that but I wanted to create struct-class with 
|dynamic attributes and additional constructors.
|
|class SubStruct < Struct
|   def new2
|     new( 'attr1_value', 'attr2_value' )
|   end
|end
|
|new2 - instance method of SubStruct (Struct) and I thought it has to be 
|class method of SubStruct.new( ... ) class.

Unlike other classes, Struct.new returns its subclass, not instance.
This is very exceptional behavior.

new2 is an instance method of SubStruct.

  class SubStruct < Struct
    def new2
       new(:foo, :bar)
    end
  end

  C = MyStruct.new(:foo)
  p C.ancestors         # => [C, MyStruct, Struct, Enumerable, Object, Kernel]
  p C.new.new2          # "new2" here.  but not "new"

							matz.