Creates a new class, named by aString, containing accessor methods for the
given symbols. If the name aString is
omitted, an anonymous structure class will be created. Otherwise, the name
of this struct will appear as a constant in class Struct, so it must be unique for all
Structs in the system and should start with a capital letter.
Assigning a structure class to a constant effectively gives the class the
name of the constant.

Struct::new returns a newClass object, which can then be used to
create specific instances of the new
structure. The number of actual parameters must be less than or equal to
the number of attributes defined for this class; unset parameters default
to \nil{}. Passing too many parameters will raise an \E{ArgumentError}.

The remaining methods listed in this section (class and instance) are
defined for this generated class.

# Create a structure with a name in StructStruct.new("Customer",:name,:address)#=> Struct::CustomerStruct::Customer.new("Dave","123 Main")#=> #<Struct::Customer name="Dave", address="123 Main"># Create a structure named by its constantCustomer=Struct.new(:name,:address)#=> CustomerCustomer.new("Dave","123 Main")#=> #<Customer name="Dave", address="123 Main">

/*
* call-seq:
* Struct.new( [aString] [, aSym]+> ) => StructClass
* StructClass.new(arg, ...) => obj
* StructClass[arg, ...] => obj
*
* Creates a new class, named by <i>aString</i>,containingaccessor*methodsforthegivensymbols.Ifthename<i>aString</i> is
* omitted, an anonymous structure class will be created. Otherwise,
* the name of this struct will appear as a constant in class
* <code>Struct</code>,soitmustbeuniqueforall*<code>Struct</code>s in the system and should start with a capital
* letter. Assigning a structure class to a constant effectively gives
* the class the name of the constant.
*
* <code>Struct::new</code>returnsanew<code>Class</code> object,
* which can then be used to create specific instances of the new
* structure. The number of actual parameters must be
* less than or equal to the number of attributes defined for this
* class; unset parameters default to \nil{}. Passing too many
* parameters will raise an \E{ArgumentError}.
*
* The remaining methods listed in this section (class and instance)
* are defined for this generated class.
*
* # Create a structure with a name in Struct
* Struct.new("Customer", :name, :address) #=> Struct::Customer
* Struct::Customer.new("Dave", "123 Main") #=> #<Struct::Customer name="Dave", address="123 Main">
*
* # Create a structure named by its constant
* Customer = Struct.new(:name, :address) #=> Customer
* Customer.new("Dave", "123 Main") #=> #<Customer name="Dave", address="123 Main">
*/staticVALUErb_struct_s_def(argc,argv,klass)intargc;VALUE*argv;VALUEklass;{VALUEname,rest;longi;VALUEst;IDid;rb_scan_args(argc,argv,"1*",&name,&rest);if(!NIL_P(name)&&SYMBOL_P(name)){rb_ary_unshift(rest,name);name=Qnil;}for(i=0;i<RARRAY(rest)->len;i++){id=rb_to_id(RARRAY(rest)->ptr[i]);RARRAY(rest)->ptr[i]=ID2SYM(id);}st=make_struct(name,rest,klass);if(rb_block_given_p()){rb_mod_module_eval(0,0,st);}returnst;}