gpt4 book ai didi

ruby - 为什么 Ruby array[array.length, count] 返回 []?

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

<分区>

Possible Duplicate:
Is there some kind of unseen Array termination in Ruby?
Array slicing in Ruby: looking for explanation for illogical behaviour (taken from Rubykoans.com)

a = %w[a b c]
a[3, 1] # => []
a[4, 1] # => nil

谁能解释为什么 a[3, 1] 返回 []?为什么不用nil呢?

谢谢。

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