D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Hash
/
Filename :
new-c.ri
back
Copy
U:RDoc::AnyMethod[iI"new:ETI"Hash::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"'Returns a new empty +Hash+ object.;To:RDoc::Markup::BlankLine o; ; [I"IThe initial default value and initial default proc for the new hash ;TI"]depend on which form above was used. See {Default Values}[rdoc-ref:Hash@Default+Values].;T@o; ; [I"2If neither an argument nor a block is given, ;TI"Minitializes both the default value and the default proc to <tt>nil</tt>:;To:RDoc::Markup::Verbatim; [I"h = Hash.new ;TI"h.default # => nil ;TI"h.default_proc # => nil ;T:@format0o; ; [I"HIf argument <tt>default_value</tt> is given but no block is given, ;TI"Ginitializes the default value to the given <tt>default_value</tt> ;TI"*and the default proc to <tt>nil</tt>:;To;; [I"h = Hash.new(false) ;TI"h.default # => false ;TI"h.default_proc # => nil ;T; 0o; ; [I"]If a block is given but no <tt>default_value</tt>, stores the block as the default proc ;TI"0and sets the default value to <tt>nil</tt>:;To;; [ I"<h = Hash.new {|hash, key| "Default value for #{key}" } ;TI"h.default # => nil ;TI"$h.default_proc.class # => Proc ;TI"0h[:nosuch] # => "Default value for nosuch" ;T; 0o; ; [I"VIf both a block and a <tt>default_value</tt> are given, raises an +ArgumentError+;T@o; ; [I"VIf the optional keyword argument +capacity+ is given, the hash will be allocated ;TI"Uwith enough capacity to accommodate this many keys without having to be resized.;T: @fileI"hash.rb;T:0@omit_headings_from_table_of_contents_below0I"�Hash.new(default_value = nil) -> new_hash Hash.new(default_value = nil, capacity: size) -> new_hash Hash.new {|hash, key| ... } -> new_hash Hash.new(capacity: size) {|hash, key| ... } -> new_hash ;T0[ I":(ifnone = (ifnone_unset = true), capacity: 0, &block);T@7FI" Hash;TcRDoc::NormalClass00