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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>label‎</code> الخاص بالصنف <code>InstructionSequence</code> في روبي}}</noinclude> [[تصنيف: Ruby]...')
 
سطر 3: سطر 3:
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby InstructionSequence]]
 
[[تصنيف: Ruby InstructionSequence]]
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها.
+
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد<code><main></code> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعيد <code><compiled></code> إذا تم تقييمه من [[Ruby/String|سلسلة نصية]].
أو يعيد ال[[Ruby/String|سلسلة نصية]] <code><main></code> إن كان التسلسل في المستوى الأعلى، أو يعيد <code><compiled></code> إذا تم تقييمه من [[Ruby/String|سلسلة نصية]].
 
على سبيل المثال ، باستخدام irb:
 
 
 
باستخدام <code>[[Ruby/InstructionSequence/compile_file|::compile_file]]</code>:
 
<syntaxhighlight lang="ruby"># /tmp/method.rb
 
def hello
 
  puts "hello, world"
 
end
 
# in irb
 
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 
> iseq.label #=> <main>‎</syntaxhighlight>
 
 
==البنية العامة==
 
==البنية العامة==
<syntaxhighlight lang="ruby"></syntaxhighlight>
+
<syntaxhighlight lang="ruby">label()</syntaxhighlight>
 
==القيمة المُعادة==
 
==القيمة المُعادة==
 +
يُعيد التابع <code>label</code> تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد<code><main></code> إن كان التسلسل في المستوى الأعلى (at the top level)، أو يعيد <code><compiled></code> إذا تم تقييمه من [[Ruby/String|سلسلة نصية]].
  
 
==أمثلة==
 
==أمثلة==
مثال على استخدام التابع <code>label‎</code>:
+
 
 +
=== المثال الأول ===
 +
مثال على استخدام التابع <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
 +
def hello
 +
  puts "hello, world"
 +
end
 +
# in irb
 +
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 +
> iseq.label #=> <main>‎</syntaxhighlight>
 
==انظر أيضا==
 
==انظر أيضا==
* التابع <code>[[Ruby/InstructionSequence/inspect|inspect]]</code>: يعيد  تمثيلًا نصيا قابلًا للقراءة لتسلسل التعليمات ، بما في ذلك <code>[[Ruby/InstructionSequence/label|label]]</code> و <code>[[Ruby/InstructionSequence/path|path]]</code>.
+
* التابع <code>[[Ruby/InstructionSequence/inspect|inspect]]</code>: يعيد  تمثيلًا نصيا قابلًا للقراءة لسلسلة التعليمات.
* التابع <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‎ في توثيق روبي الرسمي.]

مراجعة 23:21، 1 نوفمبر 2018

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

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

label()

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

يُعيد التابع 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>‎

انظر أيضا

مصادر