diff options
| author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2025-08-21 08:37:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-21 09:37:19 -0400 |
| commit | 027f4aa464f92cb4884561ef277db20f8eff5732 (patch) | |
| tree | 64900fff818ec2f05af69b7295ef3c47247128c4 /doc/string/hash.rdoc | |
| parent | b6bf44ae0f0196c58a07e13ac1bd7adafd13f8b2 (diff) | |
[DOC] Tweaks for String#hash (#14253)
Diffstat (limited to 'doc/string/hash.rdoc')
| -rw-r--r-- | doc/string/hash.rdoc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/string/hash.rdoc b/doc/string/hash.rdoc new file mode 100644 index 0000000000..fe94770ed9 --- /dev/null +++ b/doc/string/hash.rdoc @@ -0,0 +1,19 @@ +Returns the integer hash value for +self+. + +Two \String objects that have identical content and compatible encodings +also have the same hash value; +see Object#hash and {Encodings}[rdoc-ref:encodings.rdoc]: + + s = 'foo' + h = s.hash # => -569050784 + h == 'foo'.hash # => true + h == 'food'.hash # => false + h == 'FOO'.hash # => false + + s0 = "äöü" + s1 = s0.encode(Encoding::ISO_8859_1) + s0.encoding # => #<Encoding:UTF-8> + s1.encoding # => #<Encoding:ISO-8859-1> + s0.hash == s1.hash # => false + +Related: see {Querying}[rdoc-ref:String@Querying]. |
