الفرق بين المراجعتين ل"Ruby/Interrupt"
< Ruby
اذهب إلى التنقل
اذهب إلى البحث
(أنشأ الصفحة ب'يُطلق الخطأ <code>Interrupt</code> عندما يكون الفهرس المُعطى غير صالح.<syntaxhighlight lang="ruby"> a = [:foo, :bar] a.fetch(0)...') |
|||
سطر 1: | سطر 1: | ||
− | يُطلق | + | يُطلق الاستثناء<code>Interrupt</code> عند استقبال إشارة المقاطعة (interrupt signal) ، عادة لأن المستخدم ضغط على Control-C (على معظم منصات posix). وعلى هذا النحو ، فهو صنف فرعي من <code>SignalException</code>. مثلاً:<syntaxhighlight lang="ruby"> |
− | + | begin | |
− | + | puts "Press ctrl-C when you get bored" | |
− | + | loop {} | |
− | + | rescue Interrupt => e | |
+ | puts "Note: You will typically use Signal.trap instead." | ||
+ | end | ||
+ | </syntaxhighlight>ستُنتج:<syntaxhighlight lang="ruby"> | ||
+ | Press ctrl-C when you get bored | ||
− | </syntaxhighlight><noinclude>{{DISPLAYTITLE: صفحة الصنف <code>Interrupt</code> في روبي}}</noinclude> | + | </syntaxhighlight>ثم انتظر إلى أن يُقاطع بالضغط على ''Control-C، وحينها ستطبع المخرجات التالية:''<syntaxhighlight lang="ruby"> |
+ | Press ctrl-C when you get bored | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | ==مصادر<span> </span>== | ||
+ | *[http://ruby-doc.org/core-2.5.1/Interrupt.html قسم الصنف Interrupt في توثيق روبي الرسمي.]<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>Interrupt</code> في روبي}}</noinclude> | ||
[[تصنيف: Ruby]] | [[تصنيف: Ruby]] | ||
[[تصنيف: Ruby Interrupt]] | [[تصنيف: Ruby Interrupt]] | ||
− | |||
− | |||
− |
مراجعة 07:28، 17 أكتوبر 2018
يُطلق الاستثناءInterrupt
عند استقبال إشارة المقاطعة (interrupt signal) ، عادة لأن المستخدم ضغط على Control-C (على معظم منصات posix). وعلى هذا النحو ، فهو صنف فرعي من SignalException
. مثلاً:
begin
puts "Press ctrl-C when you get bored"
loop {}
rescue Interrupt => e
puts "Note: You will typically use Signal.trap instead."
end
ستُنتج:
Press ctrl-C when you get bored
ثم انتظر إلى أن يُقاطع بالضغط على Control-C، وحينها ستطبع المخرجات التالية:
Press ctrl-C when you get bored