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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IndexError</code> في روبي}}</noinclude> تصنيف: Ruby تصنيف: Ruby IndexError ==مصادر<spa...')
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IndexError</code> في روبي}}</noinclude>
+
يُطلق الخطأ <code>IndexError</code> عندما يكون الفهرس المُعطى غير صالح.<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 IndexError]]
  
 
==مصادر<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 في توثيق روبي الرسمي.]

مراجعة 11:15، 13 أكتوبر 2018

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

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

مصادر