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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
ط (مراجعة وتدقيق.)
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع <code>label‎</code> الخاص بالصنف <code>InstructionSequence</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: التابع <code>InstructionSequence.label‎</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby InstructionSequence]]
 
[[تصنيف: Ruby InstructionSequence]]
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد<code><main></code> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعيد <code><compiled></code> إذا تم تقييمه من [[Ruby/String|سلسلة نصية]].
+
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد <code><main></code> إن كان التسلسل في المستوى الأعلى (top level)، أو يعيد <code><compiled></code> إذا تم تقييمها من [[Ruby/String|سلسلة نصية]].
 
==البنية العامة==
 
==البنية العامة==
 
<syntaxhighlight lang="ruby">label()</syntaxhighlight>
 
<syntaxhighlight lang="ruby">label()</syntaxhighlight>
==القيمة المُعادة==
+
==القيمة المعادة==
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد<code><main></code> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعيد <code><compiled></code> إذا تم تقييمه من [[Ruby/String|سلسلة نصية]].
+
تعاد تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] المعطاة، أو يعاد <code><main></code> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعاد <code><compiled></code> إذا تم تقييمها من [[Ruby/String|سلسلة نصية]].
  
 
==أمثلة==
 
==أمثلة==
 
=== المثال الأول ===
 
 
مثال على استخدام التابع <code>label‎</code> مع irb:
 
مثال على استخدام التابع <code>label‎</code> مع irb:
 
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 
iseq.label
 
iseq.label
#=> "<compiled>"‎</syntaxhighlight>
+
#=> "<compiled>"‎</syntaxhighlight>مثال آخر على استخدام التابع <code>label‎</code> مع <code>[[Ruby/InstructionSequence/compile_file|compile_file]]</code>:<syntaxhighlight lang="ruby"># /tmp/method.rb
 
 
=== المثال الثاني ===
 
مثال على استخدام التابع <code>label‎</code> مع <code>[[Ruby/InstructionSequence/compile_file|compile_file]]</code>:<syntaxhighlight lang="ruby"># /tmp/method.rb
 
 
def hello
 
def hello
 
   puts "hello, world"
 
   puts "hello, world"
سطر 26: سطر 21:
 
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 
> iseq.label #=> <main>‎</syntaxhighlight>
 
> iseq.label #=> <main>‎</syntaxhighlight>
==انظر أيضا==
+
==انظر أيضًا==
* التابع <code>[[Ruby/InstructionSequence/inspect|inspect]]</code>: يعيد  تمثيلًا نصيا قابلًا للقراءة لسلسلة التعليمات.
+
* التابع <code>[[Ruby/InstructionSequence/inspect|inspect]]</code>: يحول [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها إلى سلسلة نصية قابلة للقراءة.
 
* التابع <code>[[Ruby/InstructionSequence/path|path]]</code>: يُعيد مسار [[Ruby/InstructionSequence|سلسلة التعليمات]].
 
* التابع <code>[[Ruby/InstructionSequence/path|path]]</code>: يُعيد مسار [[Ruby/InstructionSequence|سلسلة التعليمات]].
  
 
==مصادر==
 
==مصادر==
*[http://ruby-doc.org/core-2.5.1/RubyVM/InstructionSequence.html#method-i-label قسم التابع label‎ في الصنف InstructionSequence‎ في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/RubyVM/InstructionSequence.html#method-i-label قسم التابع label‎ في الصنف InstructionSequence‎ في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 07:59، 4 ديسمبر 2018

يُعيد التابع label تسمية (label) سلسلة التعليمات التي استُدعي معها، أو يعيد <main> إن كان التسلسل في المستوى الأعلى (top level)، أو يعيد <compiled> إذا تم تقييمها من سلسلة نصية.

البنية العامة

label()

القيمة المعادة

تعاد تسمية (label) سلسلة التعليمات المعطاة، أو يعاد <main> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعاد <compiled> إذا تم تقييمها من سلسلة نصية.

أمثلة

مثال على استخدام التابع label‎ مع irb:

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
#=> "<compiled>"‎

مثال آخر على استخدام التابع label‎ مع compile_file:

# /tmp/method.rb
def hello
  puts "hello, world"
end
# in irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label #=> <main>‎

انظر أيضًا

مصادر