الصنف KeyError
في روبي
< 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.
يُطلق الاستثناء KeyError
عندما لا يكون المفتاح (key) المُحدد موجودًا، وهو صنف فرعي من IndexError
.
h = {"foo" => :bar}
h.fetch("foo") #=> :bar
h.fetch("baz") #=> KeyError: key not found: "baz"
توابع الكائن العامة (Public Instance Methods)
key
يعيد المفتاح الذي تسبب في رمي الخطأ KeyError
.
receiver
يعيد المتلقي (receiver) المقترن بالاستثناء KeyError
.