diff options
| author | BurdetteLamar <burdettelamar@yahoo.com> | 2025-08-16 11:18:33 -0500 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-08-16 17:04:35 -0400 |
| commit | d96991cc37b9c73372a8d0a61c5d83a2ce5b0cbe (patch) | |
| tree | 3dcb7c007b335e2b9969d18c916aa0af3d628a63 /string.c | |
| parent | 4d0836d928839ff13580f5e5b74a40b3914d9f59 (diff) | |
[DOC] Tweaks for String#hex
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -10681,18 +10681,21 @@ rb_str_scan(VALUE str, VALUE pat) * call-seq: * hex -> integer * - * Interprets the leading substring of +self+ as a string of hexadecimal digits - * (with an optional sign and an optional <code>0x</code>) and returns the - * corresponding number; - * returns zero if there is no such leading substring: + * Interprets the leading substring of +self+ as hexadecimal; + * returns its integer value: + * + * '0xFFFF'.hex # => 65535 + * 'FFzzzFF'.hex # => 255 # Hex ends at first non-hex character, 'z'. + * 'ffzzzFF'.hex # => 255 # Case does not matter. + * '-FFzzzFF'.hex # => -255 # May have leading '-'. + * '0xFFzzzFF'.hex # => 255 # May have leading '0x'. + * '-0xFFzzzFF'.hex # => -255 # May have leading '-0x'. * - * '0x0a'.hex # => 10 - * '-1234'.hex # => -4660 - * '0'.hex # => 0 - * 'non-numeric'.hex # => 0 + * Returns zero if there is no such leading substring: * - * Related: String#oct. + * 'zzz'.hex # => 0 * + * Related: See {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString]. */ static VALUE |
