الفرق بين المراجعتين ل"Ruby/Thread/thread variable-3F"
اذهب إلى التنقل
اذهب إلى البحث
جميل-بيلوني (نقاش | مساهمات) ط (مراجعة وتدقيق.) |
|||
سطر 1: | سطر 1: | ||
− | <noinclude>{{DISPLAYTITLE: التابع <code>thread_variable? | + | <noinclude>{{DISPLAYTITLE: التابع <code>Thread.thread_variable?</code> في روبي}}</noinclude> |
[[تصنيف: Ruby]] | [[تصنيف: Ruby]] | ||
[[تصنيف: Ruby Method]] | [[تصنيف: Ruby Method]] | ||
[[تصنيف: Ruby Thread]] | [[تصنيف: Ruby Thread]] | ||
− | + | يتحقق التابع <code>thread_variable?</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز المعطى موجودًا كمتغير محلي [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable). | |
− | لاحظ | + | لاحظ أنَّ هذه المتغيرات ليست متغيرات محلية [[Ruby/Fiber|الألياف]] (fiber local variables). يرجى الاطلاع على صفحة المعامل <code>[[Ruby/Thread/index operator|[]]]</code> والتابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code> لمزيد من التفاصيل. |
==البنية العامة== | ==البنية العامة== | ||
<syntaxhighlight lang="ruby">thread_variable?(key)→ true or false</syntaxhighlight> | <syntaxhighlight lang="ruby">thread_variable?(key)→ true or false</syntaxhighlight> | ||
سطر 12: | سطر 12: | ||
[[Ruby/String|سلسلة نصية]] أو رمز. | [[Ruby/String|سلسلة نصية]] أو رمز. | ||
− | ==القيمة | + | ==القيمة المعادة== |
− | + | تعاد القيمة <code>true</code> إن كانت [[Ruby/String|السلسلة النصية]] أو الرمز <code>key</code> المعطى موجودًا كمتغير محلي [[Ruby/Thread|للمهمة الفرعية]] (thread-local variable)، وإلا فستعاد القيمة <code>false</code>. | |
==أمثلة== | ==أمثلة== | ||
سطر 21: | سطر 21: | ||
me.thread_variable?(:oliver) #=> true | me.thread_variable?(:oliver) #=> true | ||
me.thread_variable?(:stanley) #=> false</syntaxhighlight> | me.thread_variable?(:stanley) #=> false</syntaxhighlight> | ||
− | ==انظر | + | ==انظر أيضًا== |
− | * التابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code>: يُعيد | + | * التابع <code>[[Ruby/Thread/thread_variable_get|thread_variable_get]]</code>: يُعيد قيمة المتغير المحلي في [[Ruby/Thread|المهمة الفرعية]] (thread local variable) الذي تم تعيينه. |
==مصادر== | ==مصادر== | ||
− | *[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variable-3F قسم | + | *[http://ruby-doc.org/core-2.5.1/Thread.html#method-i-thread_variable-3F قسم التابع thread_variable? في الصنف Thread في توثيق روبي الرسمي.] |
المراجعة الحالية بتاريخ 08:39، 6 ديسمبر 2018
يتحقق التابع thread_variable?
إن كانت السلسلة النصية أو الرمز المعطى موجودًا كمتغير محلي للمهمة الفرعية (thread-local variable).
لاحظ أنَّ هذه المتغيرات ليست متغيرات محلية الألياف (fiber local variables). يرجى الاطلاع على صفحة المعامل []
والتابع thread_variable_get
لمزيد من التفاصيل.
البنية العامة
thread_variable?(key)→ true or false
المعاملات
key
سلسلة نصية أو رمز.
القيمة المعادة
تعاد القيمة true
إن كانت السلسلة النصية أو الرمز key
المعطى موجودًا كمتغير محلي للمهمة الفرعية (thread-local variable)، وإلا فستعاد القيمة false
.
أمثلة
مثال على استخدام التابع thread_variable?
:
me = Thread.current
me.thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver) #=> true
me.thread_variable?(:stanley) #=> false
انظر أيضًا
- التابع
thread_variable_get
: يُعيد قيمة المتغير المحلي في المهمة الفرعية (thread local variable) الذي تم تعيينه.