{"id":355901,"date":"2024-05-20T23:18:21","date_gmt":"2024-05-20T23:18:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355901"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:18:21","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355901","title":{"rendered":"<span>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0438 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 Kotlin<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/622\/c15\/433\/622c154333e8735b24a5d7d43aebcc21.png\" alt=\"\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u0444\u043e\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0430).\" title=\"\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u0444\u043e\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0430).\" width=\"788\" height=\"800\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/622\/c15\/433\/622c154333e8735b24a5d7d43aebcc21.png\"\/><\/p>\n<div><figcaption>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u0444\u043e\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0430).<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u00a0Kotlin, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0430\u00a0GitHub, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0432\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430\u00a0Medium, \u044f \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u0438\u0436\u0443, \u0447\u0442\u043e\u00a0\u0430\u0432\u0442\u043e\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u00a0\u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438 \u043d\u0435\u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439. \u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u00ab\u043d\u0435\u0438\u0434\u0435\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u00bb \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u00a0\u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0430\u0432\u0442\u043e\u0440\u044b\u00a0\u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b,\u00a0\u043b\u0438\u0431\u043e \u0433\u043e\u0440\u043e\u0434\u044f\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u0441\u0442\u044b\u043b\u0438,\u00a0\u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0434\u043b\u044f\u00a0\u0447\u0442\u0435\u043d\u0438\u044f, \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438, \u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e. <\/p>\n<p>\u0418 \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0434\u0440\u0443\u0433, ChatGPT, \u043f\u043e\u00a0\u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0432\u00a0\u043c\u043e\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445, \u0432\u0438\u0434\u0438\u043c\u043e \u043d\u0430\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043b\u043e\u0445\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u00a0\u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044f \u043d\u0430\u00a0\u0438\u0441\u0442\u0438\u043d\u0443 \u0432\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0432\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a\u00a0\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Kotlin. <\/p>\n<p>\u042d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430\u00a0\u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0432\u00a0\u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0432\u00a0Kotlin. \u041d\u043e\u00a0\u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0431\u0435\u0437\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0438 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0430\u043c. <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043a\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 <a href=\"https:\/\/github.com\/vsirotin\/Smartenesse-Kotlin\/tree\/master\/resultex\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0414\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u0440\u0435\u043a\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0440\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430\u00a0Kotlin. <\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u043d\u0435\u2011\u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430\u00a0Kotlin \u0442\u0435\u00a0\u0436\u0435, \u0447\u0442\u043e\u00a0\u0438 \u0443\u00a0\u043c\u0435\u043d\u044f:<\/p>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u00ab\u043e\u0442\u043f\u0443\u0433\u0438\u0432\u0430\u0435\u0442\u00bb \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e\u00a0\u0431\u044b\u043b\u043e \u0438 \u0441\u043e \u043c\u043d\u043e\u0439 (\u043e\u0431 \u044d\u0442\u043e\u043c\u00a0\u2014 \u043d\u0438\u0436\u0435),<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043b\u0438\u0448\u043d\u0438\u0439 \u043b\u0430\u043a\u043e\u043d\u0438\u0437\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Kotlin, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u00a0\u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u044b\u0442\u043a\u0438 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0432\u00a0Kotlin \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0437\u00a0\u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 Kotlin.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043b\u044f\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c (\u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u043c) \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438\u043b\u0438\u00a0\u043c\u0435\u043d\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0435\u2011\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u00a0\u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u043e \u043a\u0430\u043a\u00a0\u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043a\u0430\u043a\u2011\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u00ab\u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043c\u0438\u0440\u00bb \u043e\u00a0\u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0435. <\/p>\n<p>\u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0449\u0435\u043d\u0438\u044f,\u00a0\u0431\u044b\u0432\u0448\u0438\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u00a0\u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0430:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u00a0\u043a\u0430\u043a\u0443\u044e\u2011\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u044e\u044e (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u00a0\u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438\u00a0\u043e\u0431\u044a\u0435\u043a\u0442. <\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u044f\u0437\u044b\u043a\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f ( Exception), \u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u0432\u0435\u0440\u0445 \u043f\u043e\u00a0\u0441\u0442\u0435\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u043e\u00a0\u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u043c. <\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0\u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u043c\u0435\u0442\u044c \u0432\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c\u00a0\u043b\u0438\u0431\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,\u00a0\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437\u00a0\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u00a0\u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445.<\/p>\n<p>\u0412\u00a0\u043f\u0435\u0440\u0432\u043e\u043c \u0438 \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0434\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438\u00a0\u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0447\u0438\u0449\u0430\u0442\u044c. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u043c\u00bb.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 Exception (\u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434)\u00a0\u2014 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Java. \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0437\u0430\u043f\u0440\u0443\u0436\u0435\u043d \u0441\u0442\u043e\u043d\u0430\u043c\u0438 Java\u2011\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043d\u0430\u00a0\u044d\u0442\u0443 \u0442\u0435\u043c\u0443. \u041d\u0435\u00a0\u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432\u00a0\u0434\u0435\u0442\u0430\u043b\u0438, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u0432\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u00a0\u044d\u0442\u0443 \u0442\u0435\u043c\u0443: <a href=\"https:\/\/phauer.com\/2015\/checked-exceptions-are-evil\" rel=\"noopener noreferrer nofollow\">Checked Exceptions are Evil<\/a> \u0438 <a href=\"https:\/\/www.quora.com\/Why-are-exceptions-considered-bad-in-many-programming-languages-when-they-make-your-code-cleaner\" rel=\"noopener noreferrer nofollow\">Why are exceptions considered bad in many programming languages when they make your code cleaner?<\/a> <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0433\u0440\u0435\u0448\u0430\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0430\u0448\u0435\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u00a0\u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u0410\u00a0\u044d\u0442\u043e\u00a0\u2014 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u0432\u0430\u0440\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043d\u043e \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c. <\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442, \u043d\u043e\u00a0\u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u043d\u0435\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u043e\u0433\u043e \u0441\u00a0\u0442\u043e\u0447\u043a\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u2011\u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <\/p>\n<p>\u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043b\u044f\u00a0\u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432 \u0438 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u043c \u043d\u0430\u00a0\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0438\u0441\u0445\u0438\u0442\u0440\u0438\u0442\u044c\u0441\u044f \u0432\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0443\u043c\u0435\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u00a0\u043b\u0438\u0431\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f,\u00a0\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>\u041a\u0430\u043a\u00a0\u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u00a0Java \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 Result, \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0432\u00a0\u043c\u043e\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/347836\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0412\u00a0\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u0435\u0442\u043e\u0432\u0430\u043b, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 Java.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u044f\u0437\u044b\u043a\u0430 Kotlin \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0435\u0441\u0442\u044c \u0438 \u043e\u043d \u0442\u043e\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>Result<\/strong>.<\/p>\n<h2>\u0414\u043e\u0441\u0430\u0434\u043d\u043e\u0435 \u043d\u0435\u0434\u043e\u0440\u0430\u0437\u0443\u043c\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438\u00a0\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-result\/\" rel=\"noopener noreferrer nofollow\">Result<\/a> \u043c\u043d\u0435 \u0431\u0440\u043e\u0441\u0438\u043b\u043e\u0441\u044c \u0432\u00a0\u0433\u043b\u0430\u0437\u0430 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0435\u0435 \u043c\u0435\u043d\u044f \u043e\u0442\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043c\u0435\u043d\u0430) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">fun &lt;T> failure(  \u00a0\u00a0\u00a0\u00a0exception:\u00a0Throwable  ): Result&lt;T><\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u00a0Exception, \u0430\u00a0\u043d\u0435\u00a0\u0441\u00a0\u043d\u0430\u0448\u0438\u043c\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. <\/p>\n<p>\u041d\u043e\u00a0\u2014 \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u043c \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u043f\u043e\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435.<\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/\" rel=\"noopener noreferrer nofollow\"><u>Throwablel<\/u><\/a> \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438 message \u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043e\u0448\u0438\u0431\u043a\u0438\u00a0\u2014 cause. \u041e\u0431\u0430 \u0447\u043b\u0435\u043d\u0430 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043b\u0438\u00a0\u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u0430. <\/p>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u00a0\u043a\u043e\u043d\u0446\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<blockquote>\n<p><strong>Inheritors:<\/strong><\/p>\n<p>open class Error\u00a0:\u00a0<a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/index.html\" rel=\"noopener noreferrer nofollow\"><u>Throwable<\/u><\/a><\/p>\n<p>open class Exception\u00a0:\u00a0<a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/index.html\" rel=\"noopener noreferrer nofollow\"><u>Throwable<\/u><\/a><\/p>\n<\/blockquote>\n<p>\u041b\u0438\u0447\u043d\u043e \u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e \u044d\u0442\u043e \u0442\u0430\u043a: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 Exception \u0434\u043b\u044f\u00a0\u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u043b\u0430\u0441\u0441 Error \u0438\u043b\u0438\u00a0\u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u043e\u0431\u0435\u0438\u0445 \u0432\u0435\u0442\u043e\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0443\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>failure(&#8230;)<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430 Result \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432\u043e\u00a0\u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445. <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442, <strong>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Result \u043f\u0440\u0438\u00a0\u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u043e\u0448\u0438\u0431\u043e\u043a!<\/strong><\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e\u00a0\u0436\u0435, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u043d\u0430\u043d\u0438\u044f. \u0418\u0437\u00a0\u043c\u043e\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043b\u0435\u0442\u043d\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u00ab\u043a\u0440\u043e\u0432\u0430\u0432\u043e\u043c \u044d\u043d\u0442\u0435\u0440\u043f\u0440\u0430\u0439\u0437\u0435\u00bb \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e\u00a0\u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u0438\u043b\u0438\u00a0\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438 \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u00a0\u0434\u0435\u0442\u0430\u043b\u044f\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0\u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f). \u0418\u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">\/**  * Base class for representing business-specific errors.  *  * The `BusinessError` class provides a structured way to represent errors that occur within a business context.  * It includes properties such as error `code`, `message`, `details`, and an optional `cause` throwable.  *  * @param code The error code associated with the business error (optional).  * @param message A human-readable error message providing additional context (optional).  * @param details Additional details or information about the error (optional).  * @param cause The underlying cause of the error, such as an exception (optional).  *\/ open class BusinessError(     val code: String? = null,     override val message: String? = null,     val details: String? = null,     override val cause: Throwable? = null ) : Error(message, cause)<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 (\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430) \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d \u0441\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u0430? \u0412\u0435\u0434\u044c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439!<br \/> \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c (\u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0442\u0435\u0441\u0442\u0430 <a href=\"https:\/\/github.com\/vsirotin\/Smartenesse-Kotlin\/blob\/c9f8b13ba82f73f5d8a087ca4171816f92cf7e3a\/resultex\/src\/test\/kotlin\/eu\/sirotin\/kotlin\/error\/ErrorTest.kt\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>):<\/p>\n<pre><code class=\"kotlin\">assertTrue(error.stackTrace[0].toString().startsWith(\"eu.sirotin.kotlin.error.ErrorTest\"))<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u0421\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f!<\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 Result. <\/p>\n<h2>\u0427\u0435\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438 \u043a\u0430\u043a \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f<\/h2>\n<p>\u041d\u0430\u0448\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441\u00a0\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u00a0\u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u0430\u00a0\u0447\u0442\u043e\u00a0\u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u00a0\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430?<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u00a0Kotlin, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u00a0\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. (\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043d\u0430\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c\u00a0\u0431\u044b \u043c\u043e\u0447\u044c:<\/p>\n<ul>\n<li>\n<p> \u0432\u00a0\u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043b\u0438\u00a0\u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,<\/p>\n<\/li>\n<li>\n<p>\u0432\u00a0\u043a\u043e\u0434\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u043e\u0431\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043e\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u043b\u0438\u00a0\u0441\u00a0\u0441\u00a0\u043e\u0448\u0438\u0431\u043a\u043e\u0439? <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439\u00a0\u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f\u00a0\u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u00a0\u043b\u0438\u0431\u043e <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0431\u0435\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 Result, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u00ab\u043d\u0430\u0447\u0438\u043d\u043a\u0443\u00bb \u0432\u00a0\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/676\/64a\/764\/67664a76446598477d0b36801c9f1011.png\" alt=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.\" title=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.\" width=\"970\" height=\"240\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/676\/64a\/764\/67664a76446598477d0b36801c9f1011.png\"\/><\/p>\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 (\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e &#8212; \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435).\u00a0<\/p>\n<p>\u042d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u042d\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u043d\u0438\u0437\u0443. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0449\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u044d\u0442\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0435\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u201c\u00ac&#187;) \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u201cY\u201d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1e5\/f92\/1a4\/1e5f921a4c410b30bf4fbbf56750c03b.png\" alt=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.\" title=\"\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.\" width=\"902\" height=\"1908\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1e5\/f92\/1a4\/1e5f921a4c410b30bf4fbbf56750c03b.png\"\/><\/p>\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Result<\/strong>.<\/p>\n<h2>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>\u0412 Kotlin \u0435\u0441\u0442\u044c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0442 Java \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 String, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0449\u0430\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">val n = \u201c4\u201d.toInt()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 Exception.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a \u043d\u0435 \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u043d\u0438\u0447\u0430\u0435\u0442, \u0430 \u0432\u044b\u0434\u0430\u0451\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043b\u0438\u0431\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 Result.<\/p>\n<p>\u041d\u043e\u0432\u0438\u0447\u043a\u0438 \u0432 Kotlin, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0435 \u0438\u0437 Java, \u043d\u0430\u043f\u0438\u0448\u0443\u0442 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">\/**  * Converts the current string to an integer safely, handling exceptions naively.  *  * This function attempts to convert the string to an integer using the [toInt] method. If successful,  * it returns the integer as a [Result.success]. If an exception occurs during the conversion,  * it returns a [Result.failure] containing the caught exception.  *  * @return A [Result] containing the integer value if the conversion is successful, or an error result  * if an exception occurs.  *\/ private fun String.toIntSafeNaive(): Result&lt;Int>  {     return try {         \/\/ Attempt to convert the string to an integer.         val x = this.toInt()         \/\/ Return a success result with the integer value.         Result.success(x)     } catch (e: Exception) {         \/\/ Return a failure result with the caught exception.         Result.failure(e)     } }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 Kotlin \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>runCatching(&#8230;)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u0435\u0435:<\/p>\n<pre><code class=\"kotlin\">\/**  * Converts the current string to an integer safely using [runCatching].  *  * This function safely attempts to convert the string to an integer using [runCatching].  * It returns a [Result.success] containing the integer value if the conversion is successful,  * or a [Result.failure] containing the caught exception if an exception occurs.  *  * @return A [Result] containing the integer value if the conversion is successful, or an error result  * if an exception occurs.  *\/ private fun String.toIntSafe(): Result&lt;Int>  = runCatching { this.toInt() }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u201c\u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430\u201d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432 \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432\u0432\u0435\u0440\u0445\u0443.<\/p>\n<pre><code class=\"kotlin\">    \/**      * Test case for comparing two realizations of the `toIntSafe` function.      *      * This test compares the behavior of two different realizations of the `toIntSafe` function,      * one using the `toIntSafeNaive` implementation and the other using the standard `toIntSafe` function.      * It validates their results in terms of success, failure, and exception messages.      *      * - It obtains two results for successful conversions from \"21\" to an integer, one from each implementation.      * - It compares the integer values obtained from both results.      * - It verifies that both results indicate success.      * - It checks that both results do not indicate failure.      * - It obtains two results for failed conversions from \"21.1\" to an integer, one from each implementation.      * - It compares the exception messages obtained from both results.      * - It verifies that both results indicate failure.      * - It checks that both results do not indicate success.      *\/     @Test     fun `Compare realizations of Error toIntSafe`() {         \/\/ Obtain two results for successful conversions from \"21\" to an integer.         val resultSuccess1 = \"21\".toIntSafeNaive()         val resultSuccess2 = \"21\".toIntSafe()          \/\/ Compare the integer values obtained from both results.         assertEquals(resultSuccess1.getOrNull(), resultSuccess2.getOrNull())          \/\/ Verify that both results indicate success.         assertTrue(resultSuccess1.isSuccess)         assertTrue(resultSuccess2.isSuccess)          \/\/ Check that both results do not indicate failure.         assertFalse(resultSuccess1.isFailure)         assertFalse(resultSuccess2.isFailure)          \/\/ Check toString()         assertEquals(\"Success(21)\", resultSuccess1.toString())          \/\/ Obtain two results for failed conversions from \"21.1\" to an integer.         val resultFailure1 = \"21.1\".toIntSafeNaive()         val resultFailure2 = \"21.1\".toIntSafe()          \/\/ Compare the exception messages obtained from both results.         assertEquals(resultFailure1.exceptionOrNull()?.message, resultFailure2.exceptionOrNull()?.message)          \/\/ Verify that both results indicate failure.         assertTrue(resultFailure1.isFailure)         assertTrue(resultFailure2.isFailure)          \/\/ Check that both results do not indicate success.         assertFalse(resultFailure1.isSuccess)         assertFalse(resultFailure2.isSuccess)          \/\/ Check toString()         assertEquals(\"Failure(java.lang.NumberFormatException: For input string: \\\"21.1\\\")\", resultFailure1.toString())     }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u201c\u043f\u0440\u044f\u043c\u043e\u0439\u201d \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>getOrNull(&#8230;)<\/strong> \u0438 <strong>exceptionOrNull(&#8230;)<\/strong>.<\/p>\n<h2>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h2>\n<p>\u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448 \u043b\u0443\u0447\u0448\u0438\u0439 \u0434\u0440\u0443\u0433 &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0 <strong>getOrDefault(\u2026)<\/strong><\/p>\n<pre><code class=\"kotlin\">    \/**      * Test case for using the `getOrDefault` function with `toIntSafe`.      *      * This test demonstrates the usage of the `getOrDefault` function with the `toIntSafe` function to handle      * default values in case of conversion failure.      *      * - It obtains a result for a successful conversion from \"21\" to an integer using `toIntSafe`.      * - It uses `getOrDefault` to retrieve the value from the result and provide a default value (12).      * - It verifies that the obtained value matches the expected integer (21).      * - It obtains a result for a failed conversion from \"21.3\" to an integer using `toIntSafe`.      * - It uses `getOrDefault` to retrieve the value from the result and provide a default value (12).      * - It verifies that the obtained value matches the provided default value (12).      *\/     @Test     fun `Using getOrDefault`() {         \/\/ Obtain a result for a successful conversion from \"21\" to an integer using `toIntSafe`.         val result1 = \"21\".toIntSafe()          \/\/ Use `getOrDefault` to retrieve the value and provide a default value (12).         val resultValue1 = result1.getOrDefault(12)          \/\/ Verify that the obtained value matches the expected integer (21).         assertEquals(21, resultValue1)          \/\/ Obtain a result for a failed conversion from \"21.3\" to an integer using `toIntSafe`.         val result2 = \"21.3\".toIntSafe()          \/\/ Use `getOrDefault` to retrieve the value and provide a default value (12).         val resultValue2 = result2.getOrDefault(12)          \/\/ Verify that the obtained value matches the provided default value (12).         assertEquals(12, resultValue2)     }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0442\u044c \u0432 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u044d\u0442\u0430 \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<strong>getOrElse(\u2026)<\/strong><\/p>\n<pre><code class=\"kotlin\">     \/**      * Returns an error message based on the provided exception [exception].      *      * @param exception The exception that occurred during the operation.      * @return An error message based on the provided exception [exception].      *\/     private fun getFalseValue(exception: Throwable): String {         \/\/Expected format here: 'For input string: \"1.1\"'         val arr = exception.message!!.split(\"\\\"\")         return \"False format by ${arr[1]}\"     }      \/**      * Adds two strings representing integers and returns the result as a string.      *      * @param a The first input string.      * @param b The second input string.      * @return A string representing the sum of the integer values in [a] and [b], or an error message      * if the conversion or addition fails.      *\/     private fun addAsString(a: String, b: String): String {         return runCatching {             \"${a.toInt() + b.toInt()}\"}             .getOrElse { e->getFalseValue(e) }     }      \/**      * Test case for using the `getOrElse` function with the `addAsString` function.      *      * This test demonstrates the usage of the `getOrElse` function with the `addAsString` function      * to handle default values or alternative results.      *      * - It calls `addAsString` with valid inputs \"1\" and \"2\" and checks that the result is \"3\".      * - It calls `addAsString` with an invalid input \"1\" and \"1.1\" and checks that the result is \"False format by 1.1\".      *\/     @Test     fun `Using getOrElse`() {         \/\/ Call `addAsString` with valid inputs \"1\" and \"2\" and check that the result is \"3\".         val result1 = addAsString(\"1\", \"2\")         assertEquals(\"3\", result1)          \/\/ Call `addAsString` with an invalid input \"1\" and \"1.1\" and check that the result is \"False format by 1.1\".         val result2 = addAsString(\"1\", \"1.1\")         assertEquals(\"False format by 1.1\", result2)     }<\/code><\/pre>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <strong>getOrThrow(&#8230;)<\/strong><\/p>\n<pre><code class=\"kotlin\">    \/**      * Test case for using the `getOrThrow` function with the `toIntSafe` function.      *      * This test demonstrates the usage of the `getOrThrow` function with the `toIntSafe` function      * to retrieve values or throw exceptions when working with results.      *      * - It uses `runCatching` to call `toIntSafe` with an invalid input \"1.2\" and attempts to retrieve the value.      * - It asserts that an exception of type `NumberFormatException` is thrown.      * - It uses `kotlin.runCatching` to call `toIntSafe` with a valid input \"12\" and attempts to retrieve the value.      * - It asserts that no exception is thrown, indicating a successful result.      *\/     @Test     fun `Using getOrThrow`() {         \/\/ Use `runCatching` to call `toIntSafe` with an invalid input \"1.2\" and attempt to retrieve the value.         val result1 = runCatching { \"1.2\".toIntSafe().getOrThrow() }.exceptionOrNull()          \/\/ Assert that an exception of type `NumberFormatException` is thrown.         assertNotNull(result1)         assertIs&lt;NumberFormatException>(result1)          \/\/ Use `kotlin.runCatching` to call `toIntSafe` with a valid input \"12\" and attempt to retrieve the value.         val result2 = kotlin.runCatching { \"12\".toIntSafe().getOrThrow() }.exceptionOrNull()          \/\/ Assert that no exception is thrown, indicating a successful result.         assertNull(result2)     }<\/code><\/pre>\n<h2>\u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/h2>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u0441 \u0437\u0430\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Result<\/strong> \u043f\u043e\u043a\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0414\u043e\u0441\u0430\u0434\u043d\u0430\u044f \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043b\u0430\u0442\u0438\u043c \u0437\u0430 \u044d\u0442\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0447\u0430\u0441\u0442\u0438. \u041a\u043b\u0430\u0441\u0441 <strong>Result<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043e\u0431\u0430 (\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>map(..)<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0435\u0451 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>toIntSafe(\u2026)<\/strong> \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0435 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 1 \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"kotlin\">    \/**      * Increases an integer value obtained from a string by 1.      *      * This function takes a string input [x], attempts to convert it to an integer using [toIntSafe],      * and then increases the resulting integer value by 1 using the `map` function from the [Result] class.      * The final result is a [Result] containing the incremented integer value.      *      * @param x The string representing an integer.      * @return A [Result] containing the incremented integer value or an error result if the conversion fails.      *\/     private fun increase(x: String): Result&lt;Int> {         return x.toIntSafe()             .map { it + 1 }     }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043a\u0430\u043a \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Test case for using the `map` function with the `increase` function.      *      * This test demonstrates the usage of the `map` function to increment an integer value obtained from a string.      *      * - It calls the `increase` function with the valid input \"112\" and retrieves the result.      * - It asserts that the result is 113, indicating a successful increment.      * - It calls the `increase` function with an invalid input \"112.9\" and attempts to retrieve the exception.      * - It asserts that an exception of type `NumberFormatException` is thrown, indicating a failed conversion.      *\/     @Test     fun `Using map`() {         \/\/ Call the `increase` function with the valid input \"112\" and retrieve the result.         val result1 = increase(\"112\").getOrNull()!!          \/\/ Assert that the result is 113, indicating a successful increment.         assertEquals(113, result1)          \/\/ Call the `increase` function with an invalid input \"112.9\" and attempt to retrieve the exception.         val result2 = increase(\"112.9\").exceptionOrNull()!!          \/\/ Assert that an exception of type `NumberFormatException` is thrown, indicating a failed conversion.         assertNotNull(result2)         assertIs&lt;NumberFormatException>(result2)     }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u043f\u0430\u0441\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0430, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>mapCatching(\u2026)<\/strong>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0433\u0434\u0435 &#8212; \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>map(&#8230;)<\/strong> \u0438\u043b\u0438 \u0432 \u043d\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Adds two integers obtained from strings and returns the result as a [Result].      *      * This function takes two string inputs [x] and [y], attempts to convert them to integers using [toIntSafe],      * and then adds the resulting integers. The operation is performed using the `mapCatching` function from the [Result] class.      * The final result is a [Result] containing the sum of the integers or an error result if the conversion or addition fails.      *      * @param x The first string representing an integer.      * @param y The second string representing an integer.      * @return A [Result] containing the sum of the integers or an error result if the conversion or addition fails.      *\/     private fun add(x: String, y: String): Result&lt;Int> {         return x.toIntSafe()             .mapCatching { it + y.toInt() }     }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<pre><code class=\"kotlin\">     \/**      * Test case for using the `mapCatching` function with the `add` function.      *      * This test demonstrates the usage of the `mapCatching` function to add two integers obtained from strings.      *      * - It calls the `add` function with valid inputs \"112\" and \"38\" and retrieves the result.      * - It asserts that the result is 150, indicating a successful addition.      * - It calls the `add` function with invalid inputs \"112.9\" and \"38\" and attempts to retrieve the exception.      * - It asserts that an exception of type `NumberFormatException` is thrown, and the error message contains \"112.9\".      * - It calls the `add` function with valid inputs \"112\" and \"38.5\" and attempts to retrieve the exception.      * - It asserts that an exception of type `NumberFormatException` is thrown, and the error message contains \"38.5\".      *\/     @Test     fun `Using mapCatching`() {         \/\/ Call the `add` function with valid inputs \"112\" and \"38\" and retrieve the result.         val result1 = add(\"112\", \"38\").getOrNull()!!          \/\/ Assert that the result is 150, indicating a successful addition.         assertEquals(150, result1)          \/\/ Call the `add` function with invalid inputs \"112.9\" and \"38\" and attempt to retrieve the exception.         val result2 = add(\"112.9\", \"38\").exceptionOrNull()!!          \/\/ Assert that an exception of type `NumberFormatException` is thrown, and the error message contains \"112.9\".         assertNotNull(result2)         assertIs&lt;NumberFormatException>(result2)         assertTrue(result2.message!!.contains(\"112.9\"))          \/\/ Call the `add` function with valid inputs \"112\" and \"38.5\" and attempt to retrieve the exception.         val result3 = add(\"112\", \"38.5\").exceptionOrNull()!!          \/\/ Assert that an exception of type `NumberFormatException` is thrown, and the error message contains \"38.5\".         assertNotNull(result3)         assertIs&lt;NumberFormatException>(result3)         assertTrue(result3.message!!.contains(\"38.5\"))     }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 <strong>recover(\u2026)<\/strong> \u0438 <strong>recoverCatching(\u2026)<\/strong> \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <strong>map(\u2026)<\/strong> <strong>mapCatching(\u2026)<\/strong> \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"kotlin\">     \/**      * Test case for using the `recover` function with the `toIntSafe` function.      *      * This test demonstrates the usage of the `recover` function to handle exceptions when working with results.      *      * - It uses `toIntSafe` to convert \"-15\" to an integer and then uses `recover` to retrieve the result or      *   the stack trace size in case of an exception. It asserts that the result is -15.      * - It uses `toIntSafe` to convert \"-15.1\" to an integer and then uses `recover` to retrieve the result or      *   the stack trace size in case of an exception. It asserts that the stack trace size is greater than 10.      *\/     @Test     fun `Using recover`() {         \/\/ Use `toIntSafe` to convert \"-15\" to an integer and use `recover` to retrieve the result or the stack trace size.         val result1 = \"-15\".toIntSafe().recover { exception -> exception.stackTrace.size }          \/\/ Assert that the result is -15.         assertEquals(-15, result1.getOrNull())          \/\/ Use `toIntSafe` to convert \"-15.1\" to an integer and use `recover` to retrieve the result or the stack trace size.         val result2 = \"-15.1\".toIntSafe().recover { exception -> exception.stackTrace.size }          \/\/ Assert that the stack trace size is greater than 10.         assertTrue(result2.getOrNull()!! > 10)     }       \/**      * Test case for using the `recoverCatching` function with the `toIntSafe` function.      *      * This test demonstrates the usage of the `recoverCatching` function to handle exceptions when working with results.      *      * - It uses `runCatching` to call `toIntSafe` with \"-15.1\" and then uses `recover` to convert \"0.0\" to an integer      *   or retrieve an exception in case of a failure. It asserts that an exception of type `NumberFormatException` is thrown,      *   and the error message contains \"0.0\".      * - It directly uses `recoverCatching` with \"-15.1\" and converts \"0.0\" to an integer. It asserts that an exception      *   of type `NumberFormatException` is thrown, and the error message contains \"0.0\".      * - It directly uses `recoverCatching` with \"-15\" and converts \"0.0\" to an integer. It asserts that the result is -15.      * - It directly uses `recoverCatching` with \"-15.1\" and converts \"2\" to an integer. It asserts that the result is 2.      *\/     @Test     fun `Using recoverCatching`() {           \/\/ Directly use `recoverCatching` with \"-15.1\" and convert \"0.0\" to an integer.         val result2 =  \"-15.1\".toIntSafe().recoverCatching { \"0.0\".toInt() }.exceptionOrNull()          \/\/ Assert that an exception of type `NumberFormatException` is thrown, and the error message contains \"0.0\".         assertNotNull(result2)         assertIs&lt;NumberFormatException>(result2)         assertTrue(result2.message!!.contains(\"0.0\"))          \/\/ Directly use `recoverCatching` with \"-15\" and convert \"0.0\" to an integer.         val result3 =  \"-15\".toIntSafe().recoverCatching { \"0.0\".toInt() }.getOrNull()          \/\/ Assert that the result is -15.         assertEquals(-15, result3)          \/\/ Directly use `recoverCatching` with \"-15.1\" and convert \"2\" to an integer.         val result4 =  \"-15.1\".toIntSafe().recoverCatching { \"2\".toInt() }.getOrNull()          \/\/ Assert that the result is 2.         assertEquals(2, result4)     }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>fold(\u2026)<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043e\u0431\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435, \u0432 \u043e\u0434\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.\u00a0<\/p>\n<pre><code class=\"kotlin\">    \/**      * Adds two strings representing integers and returns the result as a string.      *      * @param a The first input string.      * @param b The second input string.      * @return A string representing the sum of the integer values in [a] and [b], or an error message      * if the conversion or addition fails.      *\/     private fun addAsString1(a: String, b: String): String {         return runCatching {             \"${a.toInt() + b.toInt()}\"   }             .fold(                 {\"Result: $it\"},                 {getFalseValue(it)}             )     }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 <strong>onSuccess<\/strong> \u0438 <strong>onFailure<\/strong>.<\/p>\n<pre><code class=\"kotlin\">    \/**      * Adds two strings representing integers and returns the result as a string.      *      * @param a The first input string.      * @param b The second input string.      * @return A string representing the sum of the integer values in [a] and [b], or an error message      * if the conversion or addition fails.      *\/     private fun addAsString2(a: String, b: String): String {         return runCatching {             \"${a.toInt() + b.toInt()}\"   }             .fold(                 onSuccess = {\"Result: $it\"},                 onFailure = {getFalseValue(it)}             )     }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<pre><code class=\"kotlin\">     \/**      * Test case for using the `fold` function with two different implementations of `addAsString`.      *      * This test demonstrates the usage of the `fold` function to obtain results from two different implementations      * of the `addAsString` function and verifies their correctness.      *      * - It calls `addAsString1` with valid inputs \"1\" and \"4\" and checks that the result is \"Result: 5\".      * - It calls `addAsString2` with the same valid inputs and verifies that the result is also \"Result: 5\".      * - It calls `addAsString1` with an invalid input \"1.3\" and \"4\" and checks that the result is \"False format by 1.3\".      * - It calls `addAsString2` with the same invalid inputs and verifies that the result is also \"False format by 1.3\".      *\/     @Test     fun `Using fold`() {         \/\/ Call `addAsString1` with valid inputs \"1\" and \"4\" and check that the result is \"Result: 5\".         val result1 = addAsString1(\"1\", \"4\")         assertEquals(\"Result: 5\", result1)          \/\/ Call `addAsString2` with the same valid inputs and verify that the result is also \"Result: 5\".         val result2 = addAsString2(\"1\", \"4\")         assertEquals(\"Result: 5\", result2)          \/\/ Call `addAsString1` with an invalid input \"1.3\" and \"4\" and check that the result is \"False format by 1.3\".         val result3 = addAsString1(\"1.3\", \"4\")         assertEquals(\"False format by 1.3\", result3)          \/\/ Call `addAsString2` with the same invalid inputs and verify that the result is also \"False format by 1.3\".         val result4 = addAsString2(\"1.3\", \"4\")         assertEquals(\"False format by 1.3\", result4)     }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u043e \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0443\u0442\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>onSuccess(\u2026)<\/strong> \u0438 <strong>onFailure(\u2026)<\/strong>. \u0428\u0430\u0440\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"kotlin\">    \/**      * Test case for using the `onSuccess` and `onFailure` functions with `toIntSafe`.      *      * This test demonstrates the usage of the `onSuccess` and `onFailure` functions with the `toIntSafe` function      * to handle success and failure cases and update a result variable.      *      * - It uses `toIntSafe` to convert \"3.5\" to an integer and uses `onFailure` to set the result to \"FAILURE\".      * - It asserts that the result variable is \"FAILURE\" since the conversion fails.      * - It uses `toIntSafe` to convert \"3.5\" to an integer and uses `onSuccess` to set the result to \"SUCCESS\".      * - It again uses `onFailure`, but this time after `onSuccess`, and asserts that the result remains \"FAILURE\"      * - It uses `toIntSafe` to convert \"35\" to an integer and uses `onFailure` to set the result to \"FAILURE\".      * - It asserts that the result variable is \"SUCCESS\" since the conversion is successful and `onFailure` is not called.      * - It uses `toIntSafe` to convert \"35\" to an integer and uses `onSuccess` to set the result to \"SUCCESS\".      * - It again uses `onFailure`, but this time after `onSuccess`, and asserts that the result remains \"SUCCESS\"      *   since `onFailure` will be not called.      *\/     @Test     fun `Using onSuccess and onFailure`() {         \/\/ Initialize the result variable.         var result = \"\"          \/\/ Use `toIntSafe` to convert \"3.5\" to an integer and use `onFailure` to set the result to \"FAILURE\".         \"3.5\".toIntSafe()             .onFailure { result = FAILURE }          \/\/ Assert that the result variable is \"FAILURE\" since the conversion fails.         assertEquals(FAILURE, result)          \/\/ Use `toIntSafe` to convert \"3.5\" to an integer and use `onSuccess` to set the result to \"SUCCESS\".         \/\/  but it should pass.         \"3.5\".toIntSafe()             .onSuccess { result = SUCCESS }             .onFailure { result = FAILURE }          \/\/ Assert that the result variable remains \"FAILURE\" `.         assertEquals(FAILURE, result)          result = SUCCESS         \/\/ Use `toIntSafe` to convert \"35\" to an integer and use `onFailure` to set the result to \"FAILURE\".         \"35\".toIntSafe()             .onFailure { result = FAILURE }          \/\/ Assert that the result variable is \"SUCCESS\" since the conversion is successful and the action         \/\/ of `onFailure` is not called.         assertEquals(SUCCESS, result)          \/\/ Use `toIntSafe` to convert \"35\" to an integer and use `onSuccess` to set the result to \"SUCCESS\".         \/\/ Then, use `onFailure`, but it should not override the previous `onSuccess` value.         \"35\".toIntSafe()             .onSuccess { result = SUCCESS }             .onFailure { result = FAILURE }          \/\/ Assert that the result variable remains \"SUCCESS\" since `onFailure` does not override the previous `onSuccess`         \/\/because it action was not called         assertEquals(SUCCESS, result)     }<\/code><\/pre>\n<h2>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 &#171;\u0431\u0435\u0437\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043d\u044b\u0445&#187; \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445<\/h2>\n<p>\u0412\u00a0\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Result<\/strong> \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0410\u00a0\u0447\u0442\u043e\u00a0\u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u00a0\u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441\u2011\u043b\u043e\u0433\u0438\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0435\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0438\u0441\u044c \u0432\u00a0\u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438\u00a0\u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u00a0\u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c\u0443 \u043a\u0430\u043d\u0430\u043b\u0443 \u043a\u0430\u043a\u00a0\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e\u00a0\u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u0431\u043e\u0438\u0442. \u041a\u0430\u043a\u00a0\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0431\u0435\u0437\u00a0\u0431\u0440\u043e\u0441\u0430\u043d\u0438\u044f Exception \u0432\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435?<\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437\u00a0\u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432\u00a0\u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u043e\u0437\u0440\u0430\u0436\u0430\u044e\u0449\u0435\u0439 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435, \u043a\u0430\u043a\u00a0\u0432\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u043d\u0438\u0437\u0443.<\/p>\n<p>\u041d\u043e\u00a0\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Dummy function for an action that should be executed when a value is available.      * This function is used to fix the call structure and set the 'actionWithValueExecuted' flag to true.      *      * @param ignoredValue The integer value (ignored) for which the action is performed.      *\/     private fun someActionWithValue(ignoredValue: Int) {         actionWithValueExecuted = true     }      \/**      * Dummy function for an action that should be executed when an error occurs.      * This function is used to fix the call structure and set the 'actionWithErrorExecuted' flag to true.      *      * @param ignoredError The Throwable (ignored) representing the error condition for which the action is performed.      *\/     private fun someActionWithError(ignoredError: Throwable) {         actionWithErrorExecuted = true     }<\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f &#171;\u0431\u0435\u0437\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043d\u0430\u044f&#187; \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u0442\u0435\u0441\u0442 \u043a \u043d\u0435\u0439:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Processes an integer value represented as a string, following the strategy of      * \"make something by success and throw by failure.\"      *      * @param value The string representation of an integer value.      * @return A Throwable instance if there is a conversion failure, otherwise null.      *\/     private fun processIntValue(value: String): Throwable? =         value.toIntSafe()             .onSuccess { someActionWithValue(it) }             .exceptionOrNull()          \/**     * Test case to demonstrate processing an integer value as a string and handling success and failure.     *\/     @Test     fun `Using pseudo result-less`() {          \/\/ When \"25\" is processed, it should result in a null Throwable, indicating success.         assertNull(processIntValue(\"25\"))         assertTrue(actionWithValueExecuted)          \/\/ Reset the action flag for the next test.         actionWithValueExecuted = false          \/\/ When \"25.9\" is processed, it should result in a non-null Throwable, indicating a failure.         assertNotNull(processIntValue(\"25.9\"))         assertFalse(actionWithValueExecuted)     }<\/code><\/pre>\n<h2>&#171;\u0422\u0440\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435&#187; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430\u00a0\u043b\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u00a0\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c. \u041f\u0440\u0438\u0432\u0435\u0442 \u044d\u0442\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u00a0\u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435 \u0438\u043b\u0438\u00a0\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u00a0\u043a\u043e\u0434\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u00ab\u0434\u043e\u0440\u043e\u0436\u0435\u00bb \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<p>\u0412\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u00ab\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u00bb \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/li>\n<li>\n<p>\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043ae<\/p>\n<\/li>\n<li>\n<p>\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u043a\u00a0\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e\u00a0\u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u00a0\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043e\u0436\u0438\u0434\u0430\u044f \u0447\u0442\u043e\u00a0\u044d\u0442\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0437\u043d\u0430\u043a \u00ab+\u00bb \u0438\u043b\u0438 \u00ab\u2011\u00bb, \u0430\u00a0\u0432\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 0\u00a0\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u00a0\u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435\u00a0\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u00a0\u2014 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u00a0\u0438 \u043f\u0440\u0435\u0436\u0434\u0435 \u0432 <strong>Result<\/strong>, \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u00a0\u2014 null):<\/p>\n<pre><code class=\"kotlin\">     \/**      * Attempts to extract the sign of an integer from the current [String].      *      * @return A [Result] containing the sign of the integer as a [String] (\"+\" or \"-\"), or `null` by zero      * if the operation is not applicable (e.g., for non-integer strings) [Result] contains exception.      *\/     private fun String.signOfInt(): Result&lt;String>? {         \/\/ Try to convert the string to an integer using the toIntSafe() extension function.         val result = this.toIntSafe()          \/\/ If the conversion fails, return a failure result with the exception.         if (result.isFailure) return Result.failure(result.exceptionOrNull()!!)          \/\/ Determine the sign of the integer and return it as a success result.         return when (result.getOrNull()!!.sign) {             1 -> Result.success(\"+\")             -1 -> Result.success(\"-\")             else -> null         }     }      \/**      * Test case for using the `signOfInt` function with result-less return.      *      * This test demonstrates the usage of the `signOfInt` function to obtain results and exceptions in scenarios where      * the function may return a result or no result (`null`) based on the input.      *      * - It calls the `signOfInt` function with an invalid input \"1.1\" and uses `exceptionOrNull` to retrieve the exception.      *   It asserts that an exception of type `NumberFormatException` is thrown, and the error message contains \"1.1\".      * - It calls the `signOfInt` function with a valid input \"0\" and expects the result to be `null` since \"0\" has no sign.      * - It calls the `signOfInt` function with valid inputs \"+11\" and \"-112\" and uses `getOrNull` to retrieve the result.      *   It asserts that the results are \"+\", and \"-\", respectively.      *\/     @Test     fun `Using not-applicable`() {         \/\/ Call the `signOfInt` function with an invalid input \"1.1\" and retrieve the exception.         val result1 = \"1.1\".signOfInt()?.exceptionOrNull()          \/\/ Assert that an exception of type `NumberFormatException` is thrown, and the error message contains \"1.1\".         assertNotNull(result1)         assertIs&lt;NumberFormatException>(result1)         assertTrue(result1.message!!.contains(\"1.1\"))          \/\/ Call the `signOfInt` function with a valid input \"0\" and expect the result to be `null` since \"0\" has no sign.         assertNull(\"0\".signOfInt())          \/\/ Call the `signOfInt` function with valid inputs \"+11\" and \"-112\" and retrieve the results.         val result2 = \"+11\".signOfInt()?.getOrNull()         val result3 = \"-112\".signOfInt()?.getOrNull()          \/\/ Assert that the results are \"+\", and \"-\", respectively.         assertEquals(\"+\", result2)         assertEquals(\"-\", result3)     }<\/code><\/pre>\n<h2>\u041c\u043d\u043e\u0433\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Result <\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Result<\/strong> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u0446\u0435\u043f\u043e\u0447\u043a\u0430\u0445 \u0438 \u043a\u0430\u0441\u043a\u0430\u0434\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<br \/>\u041d\u0438\u0436\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0441\u0430\u043c\u044b\u0445 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u00a0\u043f\u0440\u0435\u0431\u044b\u0432\u0430\u043d\u0438\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043b\u0438\u00a0\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u00a0\u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0435. \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0432\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u043d\u0430\u0442\u044c, \u043d\u0430\u00a0\u043a\u0430\u043a\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e\u00a0\u043c\u044b \u0445\u043e\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u00a0\u0444\u043e\u0440\u043c\u0443\u043b\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"y =ax^2 + bx + c\" alt=\"y =ax^2 + bx + c\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87d\/b7a\/efe\/87db7aefe64d5f890c4075ac3ad019a5.svg\" width=\"142\" height=\"25\"\/><\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c a, b, c \u0437\u0430\u0434\u0430\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0439. \u0412\u043e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Calculates the expression ax^2 + bx + c for given values of x, a, b, and c.      * This function employs the strategy of \"stopping normal processing by the first failure in the chain.\"      *      * @param x The value of 'x' in the equation.      * @param a The coefficient 'a' as a String.      * @param b The coefficient 'b' as a String.      * @param c The coefficient 'c' as a String.      * @return A Result&lt;Int> representing the result of the calculation or an exception if any of the conversions fail.      *\/     private fun `calculate ax2 + bx + c`(x: Int, a: String, b: String, c: String): Result&lt;Int> =         runCatching { a.toInt() * x * x }             .mapCatching { it + b.toInt() * x }             .mapCatching { it + c.toInt() }      \/**      * Test case to demonstrate chained calculations and catching the first failure.      *\/     @Test     fun `Using chained call with catching first failure`() {          \/\/ Calculate the expression successfully with valid inputs.         assertEquals(6, `calculate ax2 + bx + c`(1, \"1\", \"2\", \"3\").getOrNull()!!)          \/\/ Attempt to calculate with 'a' as a non-integer should result in an exception.         assertTrue(`calculate ax2 + bx + c`(1, \"1.1\", \"2\", \"3\").exceptionOrNull().toString().contains(\"1.1\"))          \/\/ Attempt to calculate with 'b' as a non-integer should result in an exception.         assertTrue(`calculate ax2 + bx + c`(1, \"1\", \"2.2\", \"3\").exceptionOrNull().toString().contains(\"2.2\"))          \/\/ Attempt to calculate with 'c' as a non-integer should result in an exception.         assertTrue(`calculate ax2 + bx + c`(1, \"1\", \"2\", \"3.3\").exceptionOrNull().toString().contains(\"3.3\"))     }<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u043e\u0440\u0435\u043c\u0441\u044f \u0441\u00a0\u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u00ab\u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e\u00bb. \u0422\u0430\u043a\u00a0\u0431\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u0435\u00bb \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e\u00a0\u0442\u043e\u043b\u044c\u043a\u043e \u00ab\u0447\u0438\u0441\u0442\u044b\u0435\u00bb \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0434\u0430\u0442\u044c \u043d\u0430\u00a0\u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0412\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u043d\u0438\u0437\u0443 (\u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440!:\u2011) \u043c\u044b \u043f\u0440\u0438\u00a0\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u00a0\u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438 \u0441\u00a0\u043f\u0440\u044f\u043c\u044b\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e\u00a0\u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 Double, \u0430\u00a0\u0435\u0441\u043b\u0438 \u0438 \u044d\u0442\u043e \u043d\u0435\u00a0\u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u0442\u043e \u0432\u044b\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"kotlin\">    \/**      * Converts a string to an integer using a strategy of \"trying many approaches to get a value.\"      * This function first attempts to convert the string to an integer safely. If that fails, it tries      * to convert the string to a double and then to an integer. If both conversions fail, it returns      * Int.MAX_VALUE.      *      * @return An integer value obtained from the string or Int.MAX_VALUE if all conversion attempts fail.      *\/     private fun String.toIntAnyway(): Int =         this.toIntSafe()             .recoverCatching { this.toDouble().toInt() }             .getOrDefault(Int.MAX_VALUE)      \/**      * Test cases to demonstrate the \"try many approaches to get a value\" strategy.      *\/     @Test     fun `Using chained call anyway strategy`() {          \/\/ Successfully convert \"2\" to an integer.         assertEquals(2, \"2\".toIntAnyway())          \/\/ Convert \"2.2\" to an integer after trying the double conversion.         assertEquals(2, \"2.2\".toIntAnyway())          \/\/ Convert \"23.81e5\" to an integer after trying the double conversion.         assertEquals(2381000, \" 23.81e5\".toIntAnyway())          \/\/ Conversion fails for \" Very match,\" so it returns Int.MAX_VALUE.         assertEquals(Int.MAX_VALUE, \" Very match\".toIntAnyway())     }<\/code><\/pre>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u044d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043e\u00a0\u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c\u00a0\u2014 \u0432\u0430\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u00a0\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Kotlin \u043d\u0435\u00a0\u0441\u0442\u043e\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u043b\u0438\u00a0\u043f\u0440\u0438\u0441\u043f\u043e\u0441\u0430\u0431\u043b\u0438\u0432\u0430\u0442\u044c \u0434\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441 Either \u0438\u0437\u00a0\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Arrow. \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0442\u043e, \u0447\u0442\u043e\u00a0\u0443\u0436\u0435 \u0432\u00a0\u044f\u0437\u044b\u043a\u0435 \u0438 \u0442\u0430\u043a \u0435\u0441\u0442\u044c\u00a0\u2014 \u043a\u043b\u0430\u0441\u0441 <strong>Result<\/strong>.<\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e\u00a0\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u0434\u043b\u044f\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 <a href=\"https:\/\/github.com\/vsirotin\/Smartenesse-Kotlin\/tree\/master\/resultex\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432\u0430\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 <strong>\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/strong> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Kotlin. \u0415\u0441\u043b\u0438 \u0442\u0435\u043c\u0430 \u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432\u00a0\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 <a href=\"https:\/\/habr.com\/ru\/articles\/425321\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0430<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/486632\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0430<\/a> \u0441\u0442\u0430\u0442\u044c\u0438. \u0410\u00a0\u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438, \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u0441\u044c \u0438\u043b\u0438\u00a0\u0434\u0430\u0436\u0435 \u0432\u0441\u0442\u0443\u043f\u0438\u0442\u0435 \u0432 <a href=\"https:\/\/t.me\/rpseru\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0443 \u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u2011\u0433\u0440\u0443\u043f\u043f\u0443<\/a>. <\/p>\n<p>\u0410 \u0435\u0449\u0451 \u044f \u043f\u0438\u0448\u0443 \u043a\u043d\u0438\u0433\u0443\u00a0<a href=\"https:\/\/proza.ru\/avtor\/vsirotin\" rel=\"noopener noreferrer nofollow\">\u00ab\u041c\u0435\u043c\u0443\u0430\u0440\u044b \u043a\u043e\u0447\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430: \u0431\u0430\u0439\u043a\u0438,\u00a0\u0431\u044b\u043b\u0438, \u0434\u0443\u043c\u044b\u00bb<\/a>. \u0415\u0441\u043b\u0438 \u0443\u00a0\u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u00a0\u2014 \u044f \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u0432\u0430\u0441 \u043f\u043e\u043b\u0438\u0441\u0442\u0430\u0442\u044c \u0435\u0451 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/763518\/\"> https:\/\/habr.com\/ru\/articles\/763518\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u0444\u043e\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u0430).<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u00a0Kotlin, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043d\u0430\u00a0GitHub, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0432\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430\u00a0Medium, \u044f \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u0438\u0436\u0443, \u0447\u0442\u043e\u00a0\u0430\u0432\u0442\u043e\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u00a0\u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438 \u043d\u0435\u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439. \u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u00ab\u043d\u0435\u0438\u0434\u0435\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u00bb \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u00a0\u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0430\u0432\u0442\u043e\u0440\u044b\u00a0\u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b,\u00a0\u043b\u0438\u0431\u043e \u0433\u043e\u0440\u043e\u0434\u044f\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u0441\u0442\u044b\u043b\u0438,\u00a0\u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0434\u043b\u044f\u00a0\u0447\u0442\u0435\u043d\u0438\u044f, \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438, \u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e. <\/p>\n<p>\u0418 \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0434\u0440\u0443\u0433, ChatGPT, \u043f\u043e\u00a0\u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0432\u00a0\u043c\u043e\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445, \u0432\u0438\u0434\u0438\u043c\u043e \u043d\u0430\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043b\u043e\u0445\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u00a0\u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044f \u043d\u0430\u00a0\u0438\u0441\u0442\u0438\u043d\u0443 \u0432\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0432\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a\u00a0\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Kotlin. <\/p>\n<p>\u042d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430\u00a0\u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0432\u00a0\u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c \u0432\u00a0Kotlin. \u041d\u043e\u00a0\u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0431\u0435\u0437\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0438 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0430\u043c. <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043a\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 <a href=\"https:\/\/github.com\/vsirotin\/Smartenesse-Kotlin\/tree\/master\/resultex\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0414\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u0440\u0435\u043a\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0440\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430\u00a0Kotlin. <\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u043d\u0435\u2011\u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430\u00a0Kotlin \u0442\u0435\u00a0\u0436\u0435, \u0447\u0442\u043e\u00a0\u0438 \u0443\u00a0\u043c\u0435\u043d\u044f:<\/p>\n<ul>\n<li>\n<p>\u041e\u0434\u043d\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u00ab\u043e\u0442\u043f\u0443\u0433\u0438\u0432\u0430\u0435\u0442\u00bb \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e\u00a0\u0431\u044b\u043b\u043e \u0438 \u0441\u043e \u043c\u043d\u043e\u0439 (\u043e\u0431 \u044d\u0442\u043e\u043c\u00a0\u2014 \u043d\u0438\u0436\u0435),<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043b\u0438\u0448\u043d\u0438\u0439 \u043b\u0430\u043a\u043e\u043d\u0438\u0437\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Kotlin, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u00a0\u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u044b\u0442\u043a\u0438 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0432\u00a0Kotlin \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0437\u00a0\u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 Kotlin.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043b\u044f\u00a0\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c (\u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u0432\u0430\u0436\u043d\u043e \u043a\u0430\u043a\u043e\u043c) \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438\u043b\u0438\u00a0\u043c\u0435\u043d\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0435\u2011\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u00a0\u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0442\u043e \u043a\u0430\u043a\u00a0\u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u00a0\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u00a0\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043a\u0430\u043a\u2011\u0442\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u0438\u0442\u044c \u00ab\u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043c\u0438\u0440\u00bb \u043e\u00a0\u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0435. <\/p>\n<p>\u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u0437\u0432\u0435\u0449\u0435\u043d\u0438\u044f,\u00a0\u0431\u044b\u0432\u0448\u0438\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u00a0\u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0430:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u00a0\u043a\u0430\u043a\u0443\u044e\u2011\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u044e\u044e (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u00a0\u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438\u00a0\u043e\u0431\u044a\u0435\u043a\u0442. <\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u044f\u0437\u044b\u043a\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f ( Exception), \u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u0432\u0435\u0440\u0445 \u043f\u043e\u00a0\u0441\u0442\u0435\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u043e\u00a0\u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u043c. <\/p>\n<\/li>\n<li>\n<p>\u0412\u00a0\u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u043c\u0435\u0442\u044c \u0432\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c\u00a0\u043b\u0438\u0431\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,\u00a0\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437\u00a0\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u00a0\u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445.<\/p>\n<p>\u0412\u00a0\u043f\u0435\u0440\u0432\u043e\u043c \u0438 \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0434\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438\u00a0\u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0447\u0438\u0449\u0430\u0442\u044c. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u043c\u00bb.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 Exception (\u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434)\u00a0\u2014 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u00a0Java. \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0437\u0430\u043f\u0440\u0443\u0436\u0435\u043d \u0441\u0442\u043e\u043d\u0430\u043c\u0438 Java\u2011\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043d\u0430\u00a0\u044d\u0442\u0443 \u0442\u0435\u043c\u0443. \u041d\u0435\u00a0\u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432\u00a0\u0434\u0435\u0442\u0430\u043b\u0438, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u0432\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u00a0\u044d\u0442\u0443 \u0442\u0435\u043c\u0443: <a href=\"https:\/\/phauer.com\/2015\/checked-exceptions-are-evil\" rel=\"noopener noreferrer nofollow\">Checked Exceptions are Evil<\/a> \u0438 <a href=\"https:\/\/www.quora.com\/Why-are-exceptions-considered-bad-in-many-programming-languages-when-they-make-your-code-cleaner\" rel=\"noopener noreferrer nofollow\">Why are exceptions considered bad in many programming languages when they make your code cleaner?<\/a> <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0433\u0440\u0435\u0448\u0430\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0430\u0448\u0435\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u00a0\u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u00a0\u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u0410\u00a0\u044d\u0442\u043e\u00a0\u2014 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u0432\u0430\u0440\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043d\u043e \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c. <\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442, \u043d\u043e\u00a0\u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u043d\u0435\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u043e\u0433\u043e \u0441\u00a0\u0442\u043e\u0447\u043a\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u2011\u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. <\/p>\n<p>\u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043b\u044f\u00a0\u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432 \u0438 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u043c \u043d\u0430\u00a0\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0438\u0441\u0445\u0438\u0442\u0440\u0438\u0442\u044c\u0441\u044f \u0432\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0443\u043c\u0435\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u00a0\u043b\u0438\u0431\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f,\u00a0\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>\u041a\u0430\u043a\u00a0\u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u00a0Java \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 Result, \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0432\u00a0\u043c\u043e\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/347836\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0412\u00a0\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u0435\u0442\u043e\u0432\u0430\u043b, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 Java.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u044f\u0437\u044b\u043a\u0430 Kotlin \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0435\u0441\u0442\u044c \u0438 \u043e\u043d \u0442\u043e\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>Result<\/strong>.<\/p>\n<h2>\u0414\u043e\u0441\u0430\u0434\u043d\u043e\u0435 \u043d\u0435\u0434\u043e\u0440\u0430\u0437\u0443\u043c\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0438\u00a0\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-result\/\" rel=\"noopener noreferrer nofollow\">Result<\/a> \u043c\u043d\u0435 \u0431\u0440\u043e\u0441\u0438\u043b\u043e\u0441\u044c \u0432\u00a0\u0433\u043b\u0430\u0437\u0430 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0435\u0435 \u043c\u0435\u043d\u044f \u043e\u0442\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043c\u0435\u043d\u0430) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">fun &lt;T> failure(  \u00a0\u00a0\u00a0\u00a0exception:\u00a0Throwable  ): Result&lt;T><\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u00a0Exception, \u0430\u00a0\u043d\u0435\u00a0\u0441\u00a0\u043d\u0430\u0448\u0438\u043c\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. <\/p>\n<p>\u041d\u043e\u00a0\u2014 \u043d\u0435\u00a0\u0431\u0443\u0434\u0435\u043c \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u043f\u043e\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435.<\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/\" rel=\"noopener noreferrer nofollow\"><u>Throwablel<\/u><\/a> \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438 message \u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043e\u0448\u0438\u0431\u043a\u0438\u00a0\u2014 cause. \u041e\u0431\u0430 \u0447\u043b\u0435\u043d\u0430 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043b\u0438\u00a0\u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u0430. <\/p>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u00a0\u043a\u043e\u043d\u0446\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<blockquote>\n<p><strong>Inheritors:<\/strong><\/p>\n<p>open class Error\u00a0:\u00a0<a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/index.html\" rel=\"noopener noreferrer nofollow\"><u>Throwable<\/u><\/a><\/p>\n<p>open class Exception\u00a0:\u00a0<a href=\"https:\/\/kotlinlang.org\/api\/latest\/jvm\/stdlib\/kotlin\/-throwable\/index.html\" rel=\"noopener noreferrer nofollow\"><u>Throwable<\/u><\/a><\/p>\n<\/blockquote>\n<p>\u041b\u0438\u0447\u043d\u043e \u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e \u044d\u0442\u043e \u0442\u0430\u043a: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 Exception \u0434\u043b\u044f\u00a0\u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u043b\u0430\u0441\u0441 Error \u0438\u043b\u0438\u00a0\u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u043e\u0431\u0435\u0438\u0445 \u0432\u0435\u0442\u043e\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0443\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>failure(&#8230;)<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430 Result \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432\u043e\u00a0\u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445. <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442, <strong>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Result \u043f\u0440\u0438\u00a0\u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u043e\u0448\u0438\u0431\u043e\u043a!<\/strong><\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e\u00a0\u0436\u0435, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0437\u043d\u0430\u043d\u0438\u044f. \u0418\u0437\u00a0\u043c\u043e\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043b\u0435\u0442\u043d\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u00ab\u043a\u0440\u043e\u0432\u0430\u0432\u043e\u043c \u044d\u043d\u0442\u0435\u0440\u043f\u0440\u0430\u0439\u0437\u0435\u00bb \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e\u00a0\u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u00a0\u043e\u0448\u0438\u0431\u043a\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u0438\u043b\u0438\u00a0\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043e\u0448\u0438\u0431\u043a\u0438 \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u00a0\u0434\u0435\u0442\u0430\u043b\u044f\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0\u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f). \u0418\u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<pre><code class=\"kotlin\">\/**  * Base class for representing business-specific errors.  *  * The `BusinessError` class provides a structured way to represent errors that occur within a business context.  * It includes properties such as error `code`, `message`, `details`, and an optional `cause` throwable.  *  * @param code The error code associated with the business error (optional).  * @param message A human-readable error message providing additional context (optional).  * @param details Additional details or information about the error (optional).  * @param cause The underlying cause of the error, such as an exception (optional).  *\/ open class BusinessError(     val code: String? = null,     override val message: String? = null,     val details: String? = null,     override val cause: Throwable? = null ) : Error(message, cause)<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438 (\u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430) \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d \u0441\u0442\u044d\u043a \u0432\u044b\u0437\u043e\u0432\u0430? \u0412\u0435\u0434\u044c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439!<br \/> \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c (\u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0442\u0435\u0441\u0442\u0430 <a href=\"https:\/\/github.com\/vsirotin\/Smartenesse-Kotlin\/blob\/c9f8b13ba82f73f5d8a087ca4171816f92cf7e3a\/resultex\/src\/test\/kotlin\/eu\/sirotin\/kotlin\/error\/ErrorTest.kt\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>):<\/p>\n<pre><code class=\"kotlin\">assertTrue(error.stackTrace[0].toString().startsWith(\"eu.sirotin.kotlin.error.ErrorTest\"))<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u0421\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f!<\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 Result. <\/p>\n<h2>\u0427\u0435\u0433\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438 \u043a\u0430\u043a \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f<\/h2>\n<p>\u041d\u0430\u0448\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441\u00a0\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u00a0\u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u0430\u00a0\u0447\u0442\u043e\u00a0\u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u00a0\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430?<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u00a0Kotlin, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u00a0\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. (\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438 \u043f\u043e\u0437\u0436\u0435).<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043d\u0430\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c\u00a0\u0431\u044b \u043c\u043e\u0447\u044c:<\/p>\n<ul>\n<li>\n<p> \u0432\u00a0\u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043b\u0438\u00a0\u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442,<\/p>\n<\/li>\n<li>\n<p>\u0432\u00a0\u043a\u043e\u0434\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u043e\u0431\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043e\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u043b\u0438\u00a0\u0441\u00a0\u0441\u00a0\u043e\u0448\u0438\u0431\u043a\u043e\u0439? <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439\u00a0\u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f\u00a0\u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u00a0\u043b\u0438\u0431\u043e <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0431\u0435\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 Result, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u00ab\u043d\u0430\u0447\u0438\u043d\u043a\u0443\u00bb \u0432\u00a0\u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 (\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e &#8212; \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435).\u00a0<\/p>\n<p>\u042d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u042d\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u043d\u0438\u0437\u0443. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0449\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u044d\u0442\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0435\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u201c\u00ac&#187;) \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u201cY\u201d.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Result<\/strong>.<\/p>\n<h2>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>\u0412 Kotlin \u0435\u0441\u0442\u044c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0442 Java \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 String, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0449\u0430\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">val n = \u201c4\u201d.toInt()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 Exception.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0430\u043a \u043d\u0435 \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u043d\u0438\u0447\u0430\u0435\u0442, \u0430 \u0432\u044b\u0434\u0430\u0451\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043b\u0438\u0431\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438. \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 Result.<\/p>\n<p>\u041d\u043e\u0432\u0438\u0447\u043a\u0438 \u0432 Kotlin, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0435 \u0438\u0437 Java, \u043d\u0430\u043f\u0438\u0448\u0443\u0442 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"kotlin\">\/**  * Converts the current string to an integer safely, handling exceptions naively.  *  * This function attempts to convert the string to an integer using the [toInt] method. If successful,  * it returns the integer as a [Result.success]. If an exception occurs during the conversion,  * it returns a [Result.failure] containing the caught exception.  *  * @return A [Result] containing the integer value if the conversion is successful, or an error result  * if an exception occurs.  *\/ private fun<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-355901","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355901"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355901\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}