الصنف IndexError
في روبي
< Ruby
اذهب إلى التنقل
اذهب إلى البحث
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
يُطلق الخطأ IndexError
عندما يكون الفهرس (index) المُعطى غير صالح.
a = [:foo, :bar]
a.fetch(0) #=> :foo
a[4] #=> nil
a.fetch(4) #=> IndexError: index 4 outside of array bounds: -2...2