From b9a9564c1f1359d4d4022d099d57bcb9789b692c Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Wed, 7 Aug 2024 23:36:21 +0100 Subject: [PATCH] [DOC] Tweaks for Array#[] --- array.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/array.c b/array.c index d837ff7933..2f470ee534 100644 --- a/array.c +++ b/array.c @@ -1759,12 +1759,15 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e); * In brief: * * a = [:foo, 'bar', 2] + * * # Single argument index: returns one element. * a[0] # => :foo # Zero-based index. * a[-1] # => 2 # Negative index counts backwards from end. + * * # Arguments start and length: returns an array. * a[1, 2] # => ["bar", 2] * a[-2, 2] # => ["bar", 2] # Negative start counts backwards from end. + * * # Single argument range: returns an array. * a[0..1] # => [:foo, "bar"] * a[0..-2] # => [:foo, "bar"] # Negative range-begin counts backwards from end.