diff options
author | Burdette Lamar <[email protected]> | 2024-11-06 21:19:42 -0600 |
---|---|---|
committer | <[email protected]> | 2024-11-06 22:19:42 -0500 |
commit | 0193f6c2889795014c2707d8e3dd943a303a13c3 () | |
tree | 2fc81b4a5bc60a9c25f0435a73514d13ea583083 /array.c | |
parent | b92ce6fb0d447262df4e31750cbc682d93b2fd88 (diff) |
[DOC] Doc for Array#values_at (#11960)
Notes: Merged-By: peterzhu2118 <[email protected]>
-rw-r--r-- | array.c | 111 |
1 files changed, 87 insertions, 24 deletions
@@ -3743,45 +3743,108 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx) /* * call-seq: - * array.values_at(*indexes) -> new_array * - * Returns a new +Array+ whose elements are the elements - * of +self+ at the given Integer or Range +indexes+. * - * For each positive +index+, returns the element at offset +index+: * - * a = [:foo, 'bar', 2] - * a.values_at(0, 2) # => [:foo, 2] - * a.values_at(0..1) # => [:foo, "bar"] * - * The given +indexes+ may be in any order, and may repeat: * - * a = [:foo, 'bar', 2] - * a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2] - * a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2] * - * Assigns +nil+ for an +index+ that is too large: * - * a = [:foo, 'bar', 2] - * a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil] * - * Returns a new empty +Array+ if no arguments given. * - * For each negative +index+, counts backward from the end of the array: * - * a = [:foo, 'bar', 2] - * a.values_at(-1, -3) # => [2, :foo] * - * Assigns +nil+ for an +index+ that is too small: * - * a = [:foo, 'bar', 2] - * a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2] * - * The given +indexes+ may have a mixture of signs: * - * a = [:foo, 'bar', 2] - * a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2] * */ static VALUE |