gpt4 book ai didi

ruby - 当索引为数组末尾时为空数组

转载 作者:数据小太阳 更新时间:2023-10-29 08:03:19 25 4
gpt4 key购买 nike

<分区>

Negative indices count backward from the end of the array (-1 is the last element). For start and range cases the starting index is just before an element. Additionally, an empty array is returned when the starting index for an element range is at the end of the array.

Returns nil if the index (or starting index) are out of range.

为什么

a = [0,1,2,3,4]
a[4] #=> 4
a[4,0] #=> [] - length is 0, so empty array is returned

a[5] #=> nil - makes sense since it is out of range
a[5,0] #=> [] - why is this empty?
a[6,0] #=> nil - but this is nil?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com