D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Object
/
Filename :
hash-i.ri
back
Copy
U:RDoc::AnyMethod[iI" hash:ETI"Object#hash;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"SGenerates an Integer hash value for this object. This function must have the ;FI"Pproperty that <code>a.eql?(b)</code> implies <code>a.hash == b.hash</code>.;Fo:RDoc::Markup::BlankLine o; ; [I"OThe hash value is used along with #eql? by the Hash class to determine if ;FI"Otwo objects reference the same hash key. Any hash value that exceeds the ;FI"@capacity of an Integer will be truncated before being used.;F@o; ; [ I"MThe hash value for an object may not be identical across invocations or ;FI"Kimplementations of Ruby. If you need a stable identifier across Ruby ;FI"Qinvocations and implementations you will need to generate one with a custom ;FI"method.;F@o; ; [I"MCertain core classes such as Integer use built-in hash calculations and ;FI":do not call the #hash method when used as a hash key.;F@o; ; [I"IWhen implementing your own #hash based on multiple values, the best ;FI"Opractice is to combine the class and any values using the hash code of an ;FI"array:;F@o; ; [I"For example:;F@o:RDoc::Markup::Verbatim; [I"def hash ;TI"" [self.class, a, b, c].hash ;TI" end ;T:@format0o; ; [I"MThe reason for this is that the Array#hash method already has logic for ;FI";safely and efficiently combining multiple hash values.;F: @fileI" object.c;T:0@omit_headings_from_table_of_contents_below0I"obj.hash -> integer ;F0[ I"();T@0FI"Object;TcRDoc::NormalClass00