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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'يُطلق الخطأ <code>IndexError</code> عندما يكون الفهرس المُعطى غير صالح.<syntaxhighlight lang="ruby"> a = [:foo, :bar] a.fetch(0)...')
 
سطر 1: سطر 1:
يُطلق الخطأ <code>IndexError</code> عندما يكون الفهرس المُعطى غير صالح.<syntaxhighlight lang="ruby">
+
يمثل الصنف <code>Integer</code> الأعداد الصحيحة. لا يمكن إضافة تابع أحادي (singleton method) إلى كائن من  الصنف <code>Integer</code>، وأي محاولة لفعل ذلك ستؤدي إلى إطلاق الخطأ <code>TypeError</code>.<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>Integer</code> في روبي}}</noinclude>
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>Integer</code> في روبي}}</noinclude>
 
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Integer]]
 
[[تصنيف: Ruby Integer]]
  
 
==مصادر<span> </span>==
 
==مصادر<span> </span>==
*[http://ruby-doc.org/core-2.5.1/IndexError.html قسم  الصنف Integer في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/Integer.html قسم  الصنف Integer في توثيق روبي الرسمي.]

مراجعة 22:45، 15 أكتوبر 2018

يمثل الصنف Integer الأعداد الصحيحة. لا يمكن إضافة تابع أحادي (singleton method) إلى كائن من الصنف Integer، وأي محاولة لفعل ذلك ستؤدي إلى إطلاق الخطأ TypeError.

مصادر