标签: ruby
irb会话如下:
irb
>> ar = [:peanute, :butter, :and, :jelly] => [:peanute, :butter, :and, :jelly] >> ar[0, 1] => [:peanute] >> ar[4, 1] => [] >> ar[5, 1] => nil
为什么ar [4,1]不像ar [5,1]那样返回nil?有人会解释这种行为吗?
nil
答案 0 :(得分:2)
documentation中提到了这一特例。