الصنف IOError
في روبي
< Ruby
اذهب إلى التنقل
اذهب إلى البحث
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
يُطلق الاستثناء IOError
عند فشل عملية إدخال/إخراج (IO operation) في روبي.
File.open("/etc/hosts") {|f| f << "example"}
#=> IOError: not opened for writing
File.open("/etc/hosts") {|f| f.close; f.read }
#=> IOError: closed stream
تذكر أنَّ فشل بعض عمليات الإدخال/الإخراج قد يؤدي إلى إطلاق الاستثناء SystemCallError
، وهذا الاستثناء ليس متفرع من الصنف IOError
.
File.open("does/not/exist")
#=> Errno::ENOENT: No such file or directory - does/not/exist