الفرق بين المراجعتين ل"Ruby/InstructionSequence/path"
< Ruby | InstructionSequence
اذهب إلى التنقل
اذهب إلى البحث
(أنشأ الصفحة ب'<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|سلسلة التعليمات]] | + | ==البنية العامة== |
− | على | + | <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> | ||
− | + | === المثال الثاني === | |
− | <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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==انظر أيضا== | ==انظر أيضا== | ||
* التابع <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
انظر أيضا
- التابع
label
: يُعيد تسمية (label) سلسلة التعليمات . - التابع
to_a
: يُعيد مصفوفة (Array
) تتألف من 14 عنصرًا يمثلون سلسلة التعليمات بالبيانات التالية: