الفرق بين المراجعتين ل"Ruby/IndexError"

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IndexError</code> في روبي}}</noinclude> تصنيف: Ruby تصنيف: Ruby IndexError ==مصادر<spa...')
 
ط (مراجعة وتدقيق)
 
(مراجعة متوسطة واحدة بواسطة مستخدم واحد آخر غير معروضة)
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IndexError</code> في روبي}}</noinclude>
+
يُطلق الخطأ <code>IndexError</code> عندما يكون الفهرس (index) المُعطى غير صالح.<syntaxhighlight lang="ruby">
 +
a = [:foo, :bar]
 +
a.fetch(0)  #=> :foo
 +
a[4]        #=> nil
 +
a.fetch(4)  #=> IndexError: index 4 outside of array bounds: -2...2
 +
</syntaxhighlight><noinclude>{{DISPLAYTITLE:الصنف <code>IndexError</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
[[تصنيف: Ruby IndexError]]
+
[[تصنيف: Ruby Class]]
 +
[[تصنيف: Ruby Error]]
  
 
==مصادر<span> </span>==
 
==مصادر<span> </span>==
*[http://ruby-doc.org/core-2.5.1/ENV.html قسم  الصنف ENV في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/IndexError.html صفحة الصنف IndexError في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 07:02، 13 نوفمبر 2018

يُطلق الخطأ IndexError عندما يكون الفهرس (index) المُعطى غير صالح.

a = [:foo, :bar]
a.fetch(0)   #=> :foo
a[4]         #=> nil
a.fetch(4)   #=> IndexError: index 4 outside of array bounds: -2...2

مصادر