summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files 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)
/*
* 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.
*/