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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع <code>path‎</code> الخاص بالصنف <code>InstructionSequence</code> في روبي}}</noinclude> تصنيف: Ruby...')
 
سطر 3: سطر 3:
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby Method]]
 
[[تصنيف: Ruby InstructionSequence]]
 
[[تصنيف: Ruby InstructionSequence]]
يُعيد مسار [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها.
+
يُعيد التابع <code>path</code> مسار [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد <code><compiled></code> إذا تم تقييم [[Ruby/InstructionSequence|سلسلة التعليمات]] انطلاقًا من [[Ruby/String|سلسلة نصية]].
أو يعيد <code><compiled></code> إذا تم تقييم [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها من [[Ruby/String|سلسلة نصية]].
+
==البنية العامة==
على سبيل المثال ، باستخدام irb:
+
<syntaxhighlight lang="ruby">path()</syntaxhighlight>
 +
==القيمة المُعادة==
 +
يُعيد التابع <code>path</code> مسار [[Ruby/InstructionSequence|سلسلة التعليمات]] التي استُدعي معها، أو يعيد <code><compiled></code> إذا تم تقييم [[Ruby/InstructionSequence|سلسلة التعليمات]] انطلاقًا من [[Ruby/String|سلسلة نصية]].
 +
 
 +
==أمثلة==
 +
 
 +
=== المثال الأول ===
 +
مثال على استخدام التابع <code>path‎</code> مع irb:
 +
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 +
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 +
iseq.path
 +
#=> "<compiled>"‎</syntaxhighlight>
  
باستخدام <code>[[Ruby/InstructionSequence/compile_file|::compile_file]]</code>:
+
=== المثال الثاني ===
<syntaxhighlight lang="ruby"># /tmp/method.rb
+
مثال على استخدام التابع <code>path‎</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"
سطر 15: سطر 26:
 
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
 
> iseq.path #=> /tmp/method.rb‎</syntaxhighlight>
 
> iseq.path #=> /tmp/method.rb‎</syntaxhighlight>
==البنية العامة==
 
<syntaxhighlight lang="ruby">‎</syntaxhighlight>
 
==القيمة المُعادة==
 
  
==أمثلة==
 
مثال على استخدام التابع <code>path‎</code>:
 
<syntaxhighlight lang="ruby">iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
 
#=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
 
iseq.path
 
#=> "<compiled>"‎</syntaxhighlight>
 
 
==انظر أيضا==
 
==انظر أيضا==
 
* التابع <code>[[Ruby/InstructionSequence/label|label]]</code>: يُعيد  تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] .
 
* التابع <code>[[Ruby/InstructionSequence/label|label]]</code>: يُعيد  تسمية (label) [[Ruby/InstructionSequence|سلسلة التعليمات]] .

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

يُعيد التابع path مسار سلسلة التعليمات التي استُدعي معها، أو يعيد <compiled> إذا تم تقييم سلسلة التعليمات انطلاقًا من سلسلة نصية.

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

path()

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

يُعيد التابع path مسار سلسلة التعليمات التي استُدعي معها، أو يعيد <compiled> إذا تم تقييم سلسلة التعليمات انطلاقًا من سلسلة نصية.

أمثلة

المثال الأول

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

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

المثال الثاني

مثال على استخدام التابع path‎ مع compile_file:

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

انظر أيضا

مصادر