Project

General

Profile

Bug #6680 » rdoc_for_array_and_string_slice.patch

stomar (Marcus Stollsteimer), 07/01/2012 07:27 AM

View differences:

array.c (Arbeitskopie)
* or returns a subarray starting at +start+ and
* continuing for +length+ elements, or returns a subarray
* specified by +range+.
* In the latter two cases, the start value identifies the place
* just before an element.
* Negative indices count backward from the end of the
* array (-1 is the last element). Returns +nil+ if the index
* (or starting index) are out of range.
......
* a[-3, 3] #=> [ "c", "d", "e" ]
* # special cases
* a[5] #=> nil
* a[6, 1] #=> nil
* a[5, 1] #=> []
* a[5..10] #=> []
*
......
* Element Assignment --- Sets the element at +index+, or replaces a subarray
* from +start+ for +length+ elements, or replaces a subarray specified by
* +range+.
* In the latter two cases, the start value identifies the place
* just before an element.
*
* If indices are greater than the current capacity of the array, the array
* grows automatically. Negative indices will count backward from the end of
......
* a[-1] = "Z" #=> ["A", "Z"]
* a[1..-1] = nil #=> ["A", nil]
* a[1..-1] = [] #=> ["A"]
* a[0, 0] = [ 1, 2 ] #=> [1, 2, "A"]
* a[3, 0] = "B" #=> [1, 2, "A", "B"]
*/
static VALUE
string.c (Arbeitskopie)
* substring of one character at that position. If passed two <code>Fixnum</code>
* objects, returns a substring starting at the offset given by the first, and
* with a length given by the second. If passed a range, its beginning and end
* are interpreted as offsets delimiting the substring to be returned. In all
* three cases, if an offset is negative, it is counted from the end of <i>str</i>.
* are interpreted as offsets delimiting the substring to be returned.
* In the latter two cases, the offset identifies the place just before a substring.
* In all three cases, if an offset is negative, it is counted from the end
* of <i>str</i>.
* Returns <code>nil</code> if the initial offset falls outside the string or
* the length is negative.
*
......
* a[7..-2] #=> "her"
* a[-4..-2] #=> "her"
* a[-2..-4] #=> ""
* a[11, 0] #=> ""
* a[11] #=> nil
* a[12, 0] #=> nil
* a[12..-1] #=> nil
* a[/[aeiou](.)\1/] #=> "ell"
* a[/[aeiou](.)\1/, 0] #=> "ell"
(1-1/4)