[DOC] Fix String#getbyte doc
* String#getbyte returns `nil` if `index` is out of range. * Add String#getbyte example with nil output. * Modify String#getbyte example to use negative index.
This commit is contained in:
parent
1a20bb1c98
commit
347c3faf8e
Notes:
git
2022-03-01 10:06:10 +09:00
Merged: https://github.com/ruby/ruby/pull/5586 Merged-By: nobu <nobu@ruby-lang.org>
11
string.c
11
string.c
@ -6070,13 +6070,14 @@ rb_str_chr(VALUE str)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* getbyte(index) -> integer
|
* getbyte(index) -> integer or nil
|
||||||
*
|
*
|
||||||
* Returns the byte at zero-based +index+ as an integer:
|
* Returns the byte at zero-based +index+ as an integer, or +nil+ if +index+ is out of range:
|
||||||
*
|
*
|
||||||
* s = 'abcde' # => "abcde"
|
* s = 'abcde' # => "abcde"
|
||||||
* s.getbyte(0) # => 97
|
* s.getbyte(0) # => 97
|
||||||
* s.getbyte(1) # => 98
|
* s.getbyte(-1) # => 101
|
||||||
|
* s.getbyte(5) # => nil
|
||||||
*
|
*
|
||||||
* Related: String#setbyte.
|
* Related: String#setbyte.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user