ruby-changes:71299
From: Mau <ko1@a...>
Date: Tue, 1 Mar 2022 10:06:01 +0900 (JST)
Subject: [ruby-changes:71299] 347c3faf8e (master): [DOC] Fix String#getbyte doc
https://git.ruby-lang.org/ruby.git/commit/?id=347c3faf8e From 347c3faf8eba55cdb09861c29f8646d78053fa5c Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno <maumagnaguagno@g...> Date: Mon, 28 Feb 2022 22:05:49 -0300 Subject: [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. --- string.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/string.c b/string.c index 4b35b076e0..55cdace9f8 100644 --- a/string.c +++ b/string.c @@ -6070,13 +6070,14 @@ rb_str_chr(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L6070 /* * 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.getbyte(0) # => 97 - * s.getbyte(1) # => 98 + * s = 'abcde' # => "abcde" + * s.getbyte(0) # => 97 + * s.getbyte(-1) # => 101 + * s.getbyte(5) # => nil * * Related: String#setbyte. */ -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/