{"id":9813,"date":"2018-07-11T20:52:36","date_gmt":"2018-07-11T20:52:36","guid":{"rendered":"http:\/\/bestkora.com\/IosDeveloper\/?p=9813"},"modified":"2018-12-01T14:04:13","modified_gmt":"2018-12-01T14:04:13","slug":"a-tale-of-two-flat-maps","status":"publish","type":"post","link":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/","title":{"rendered":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap"},"content":{"rendered":"<p><span style=\"font-weight: 400;\"><strong>Swift<\/strong> \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0442\u0430\u0447\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438 \u043d\u0430 <strong>Objective-C<\/strong> \u0438 \u0432\u043e\u0448\u043b\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0432 <strong>Swift<\/strong> (\u0443 <strong>Objective-C<\/strong> \u0438 <strong>Swift<\/strong> \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 <strong>SDK<\/strong>), \u0442\u043e \u0447\u0430\u0441\u0442\u044c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043d\u0438, \u0438\u0437\u0440\u0435\u0434\u043a\u0430 &#171;\u043f\u043e\u0431\u043b\u0435\u0441\u043a\u0438\u0432\u0430\u044f&#187; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438. \u041d\u043e \u0432\u043e\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 <a href=\"https:\/\/www.pointfree.co\"><strong>pointfree.co<\/strong><\/a>, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 <strong>Swift<\/strong>. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043a\u0430\u0441\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a (<strong>overload<\/strong>) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0432 <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong>. \u041d\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u0432\u043e\u0434 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0445\u043e\u0434 \u043c\u044b\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0421\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u0441 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 (<strong>overload<\/strong>) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043b\u0438\u0448\u044c \u0438\u0441\u043f\u044b\u0442\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u0442 <strong><a href=\"https:\/\/habr.com\/company\/badoo\/blog\/414809\/\" target=\"_blank\" rel=\"noopener\">\u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u0443\u0437\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f<\/a><\/strong>, \u0430 \u0433\u0443\u0440\u0443 \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u0435\u0442 <strong><a href=\"https:\/\/www.pointfree.co\/episodes\/ep10-a-tale-of-two-flat-maps\" target=\"_blank\" rel=\"noopener\">\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0439<\/a><\/strong>, \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0430\u0440\u0441\u0435\u043d\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Swift.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (<strong>overload<\/strong>) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445? \u041c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u044d\u0442\u043e \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043a\u043e\u0434!<\/span><\/p>\n<p><!--more--><\/p>\n<hr \/>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>00:05<br \/>\n<span style=\"font-weight: 400;\">\u0414\u043b\u044f <strong>Swift 4.1<\/strong> \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u044f\u044e\u0449\u0435\u0435 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a (overloads) <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043e\u043a <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u0438 \u0434\u0430\u044e\u0449\u0435\u0435 \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0435\u043d\u043e \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e, \u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e, \u0445\u043e\u0442\u044c \u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c.<br \/>\n00:37<br \/>\n\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u043e \u0442\u043e\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u0432\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u0439. \u041c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e-\u043d\u043e\u0432\u043e\u043c\u0443 \u0438 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e.<\/span><\/p>\n<h2>\u0421\u043a\u0430\u0437 \u043e \u0434\u0432\u0443\u0445 flatMap<\/h2>\n<p>01:02<br \/>\n<span style=\"font-weight: 400;\">\u0421 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430, <strong>Swift<\/strong> \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong>, <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong>, <strong><span style=\"color: #5c2699;\">reduce<\/span><\/strong>, \u0438\u00a0<strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.<\/span><\/p>\n<p>01:02<br \/>\n<span style=\"font-weight: 400;\"><strong>Swift 1.0<\/strong> \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0441\u044f \u0441 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <strong><span style=\"color: #5c2699;\">Array<\/span><\/strong> \u0441 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0432\u0441\u0435\u043c \u043d\u0430\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">\/\/ extension Array {\r\n\/\/   func flatMap&lt;B&gt;(_ f: @escaping (Element) -&gt; [B]) -&gt; [B] {\r\n\/\/   }\r\n\/\/ }<\/pre>\n<p>01:34<br \/>\n<span style=\"font-weight: 400;\">\u042d\u0442\u043e \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u044b.<\/span><\/p>\n<p>01:40<br \/>\n<span style=\"font-weight: 400;\">\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441\u0442\u0440\u043e\u043a\u0443, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438 \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u201c\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\u201d:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">let csv = \"\"\"\r\n1,2,3,4\r\n3,5,2\r\n8,9,4\r\n\"\"\"<\/pre>\n<p>01:49<br \/>\n<span style=\"font-weight: 400;\">\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436 \u0437\u0430\u043f\u044f\u0442\u044b\u0445.<br \/>\n01:54<br \/>\n<span style=\"font-weight: 400;\">\u041c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c.<\/span><\/span><\/p>\n<pre class=\"lang:swift decode:true \">csv\r\n  .split(separator: \"\\n\")\r\n\/\/ [\"1,2,3,4\", \"3,5,2\", \"8,9,4\"]<\/pre>\n<p>02:03<br \/>\n<span style=\"font-weight: 400;\">\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u044b\u0440\u043d\u0443\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u044f\u0442\u044b\u043c.<br \/>\n02:10<br \/>\n<span style=\"font-weight: 400;\">\u041d\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432.<\/span><\/span><\/p>\n<pre class=\"lang:swift decode:true\">csv\r\n  .split(separator: \"\\n\")\r\n  .map { $0.split(separator: \",\") }\r\n\/\/ [[\"1\", \"2\", \"3\", \"4\"], [\"3\", \"5\", \"2\"], [\"8\", \"9\", \"4\"]]<\/pre>\n<p>02:19<br \/>\n<span style=\"font-weight: 400;\">\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 (<strong>nested<\/strong>) \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0430 \u043d\u0443\u0436\u0435\u043d-\u0442\u043e \u043d\u0430\u043c \u00ab\u043f\u043b\u043e\u0441\u043a\u0438\u0439\u00bb \u043c\u0430\u0441\u0441\u0438\u0432.<br \/>\n02:33<br \/>\n<span style=\"font-weight: 400;\">\u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041e\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u0437\u0430\u0442\u0435\u043c \u00ab\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u00bb (<strong>flatten<\/strong>) \u0435\u0433\u043e.<\/span><\/span><\/p>\n<pre class=\"lang:swift decode:true\">csv\r\n  .split(separator: \"\\n\")\r\n  .flatMap { $0.split(separator: \",\") }\r\n\/\/ [\"1\", \"2\", \"3\", \"4\", \"3\", \"5\", \"2\", \"8\", \"9\", \"4\"]<\/pre>\n<p>02:41<br \/>\n<span style=\"font-weight: 400;\">\u0412\u0441\u043a\u043e\u0440\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 <strong>Swift<\/strong> \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0434\u043b\u044f <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">\/\/ extension Optional {\r\n\/\/   func flatMap&lt;B&gt;(_ f: @escaping (Element) -&gt; B?) -&gt; B? {\r\n\/\/   }\r\n\/\/ }<\/pre>\n<p>03:00<br \/>\n<span style=\"font-weight: 400;\">\u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>.<\/span><\/p>\n<p>03:04<\/p>\n<p><span style=\"font-weight: 400;\">\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0443 \u0441\u0442\u0440\u043e\u043a\u0438 <strong><span style=\"color: #5c2699;\">String<\/span><\/strong> \u0435\u0441\u0442\u044c \u201c\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f\u201d (<strong>failable<\/strong>) \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 <strong><span style=\"color: #5c2699;\">Data<\/span><\/strong>, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong><span style=\"color: #5c2699;\">Optional &lt;String&gt;<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">String(data: Data(), encoding: .utf8)\r\n\/\/ Optional(\"\")<\/pre>\n<p><span style=\"font-weight: 400;\">\u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u043d\u0430 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u00ab\u0437\u0430\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u0435\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 <strong><span style=\"color: #5c2699;\">Optional &lt;String&gt;<\/span><\/strong> \u0432 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">String(data: Data(), encoding: .utf8)\r\n  .map(Int.init)\r\n\/\/ Optional(nil)<\/pre>\n<p>03:24<\/p>\n<p><span style=\"font-weight: 400;\">\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 <strong><span style=\"color: #5c2699;\">Int<\/span><\/strong> \u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c. \u0422\u0438\u043f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 <strong><span style=\"color: #5c2699;\">Optional&lt;Int&gt;<\/span><\/strong>?<\/span><\/p>\n<pre class=\"theme:xcode lang:swift decode:true\"><span style=\"font-weight: 400;\">_: Int? = \u00a0String(data: Data(), encoding: .utf8)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0.map(Int.init)<\/span>\r\n<span style=\"font-weight: 400;\">\/\/ Optional \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 'Int??' \u043d\u0435 \u201c\u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u043e\u201d<\/span><\/pre>\n<p>03:37<br \/>\n<span style=\"font-weight: 400;\">\u0412\u043e\u0442 \u0438 \u043d\u0435\u0442! \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e \u0434\u0432\u043e\u0439\u043d\u043e\u0433\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c <strong><span style=\"color: #5c2699;\">Int??<\/span><\/strong>. \u041c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u043d\u0430\u0434 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u0432\u0435\u0440\u043d\u0443\u0432\u0448\u0438\u0439 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>! \u041f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">_: Int? =  String(data: Data(), encoding: .utf8)\r\n  .flatMap(Int.init)\r\n\/\/ nil<\/pre>\n<p>03:53<br \/>\n<span style=\"font-weight: 400;\">\u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u00ab\u043f\u043b\u043e\u0441\u043a\u0438\u043c\u00bb. \u0412\u0441\u0451 \u0435\u0449\u0451 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">String(data: Data([55]), encoding: .utf8)\r\n  .flatMap(Int.init)\r\n\/\/ Optional(7)<\/pre>\n<p>04:00<br \/>\n<span style=\"font-weight: 400;\">\u0421 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0432\u0437\u044f\u0442\u044c <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0441\u0442\u0440\u043e\u043a\u0443, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u0435\u0451 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u201c\u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c\u201d (<strong>flatten<\/strong>) \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0446\u0435\u043b\u043e\u0435.<\/span><\/p>\n<p>04:10<br \/>\n<span style=\"font-weight: 400;\">\u0411\u044b\u043b \u0435\u0449\u0451 \u0442\u0440\u0435\u0442\u0438\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <strong><span style=\"color: #5c2699;\">Array<\/span><\/strong> (\u0447\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0440\u0430\u0437\u043c\u044b\u0432\u0430\u043d\u0438\u044e \u0441\u043c\u044b\u0441\u043b\u0430): \u043e\u043d \u0431\u0440\u0430\u043b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043b \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>. \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">[\"1\", \"2\", \"buckle\", \"my\", \"shoe\"]<\/pre>\n<p><span style=\"font-weight: 400;\"><strong><span style=\"color: #5c2699;\">map<\/span><\/strong>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">[\"1\", \"2\", \"buckle\", \"my\", \"shoe\"]\r\n  .map(Int.init)\r\n\/\/ [{some 1}, {some 2}, nil, nil, nil]<\/pre>\n<p>04:30<br \/>\n<span style=\"font-weight: 400;\">\u041d\u0430\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432, \u0433\u0434\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0451\u0440\u043d\u0443\u0442\u044b \u0432 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>, \u0430 \u043d\u0435\u0443\u0434\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0432\u043d\u044b <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>.<\/span><\/p>\n<p>04:40<br \/>\n<span style=\"font-weight: 400;\">\u0415\u0441\u043b\u0438 \u0431\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u0438\u0445 <strong><span style=\"color: #5c2699;\">nils<\/span><\/strong> \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c <strong><span style=\"color: #5c2699;\">Ints<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">[\"1\", \"2\", \"buckle\", \"my\", \"shoe\"]\r\n  .flatMap(Int.init)\r\n\/\/ [1, 2]<\/pre>\n<p>04:47<br \/>\n<span style=\"font-weight: 400;\">\u0427\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e! \u0412\u0435\u0434\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e. \u041d\u043e \u0432\u043e\u0442 \u044d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430\u043c\u0438 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>.<\/span><\/p>\n<p>05:01<br \/>\n<span style=\"font-weight: 400;\">\u0412\u0441\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0435\u0449\u0451 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043c\u0435\u0441\u0442\u0435. \u0412\u043e\u0437\u044c\u043c\u0451\u043c-\u043a\u0430 \u043d\u0430\u0448 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 CSV \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0446\u0435\u043b\u043e\u0435 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0438\u0445.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">csv.split(separator: \"\\n\")\r\n  .flatMap { $0.split(separator: \",\") }\r\n  .flatMap { Int($0) }\r\n  .reduce(0, +)\r\n\/\/ 41<\/pre>\n<p>05:51<br \/>\n<span style=\"font-weight: 400;\">\u0417\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0432\u044b\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438 \u0438 \u00ab\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435\u00bb \u0438\u0445 \u0432 \u00ab\u043f\u043b\u043e\u0441\u043a\u0438\u0439\u00bb \u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c <strong><span style=\"color: #5c2699;\">Int<\/span><\/strong> \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0434\u043b\u044f \u043d\u0438\u0445, \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u0438\u0445 \u0441\u0445\u043e\u0434\u0443 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0443\u0434\u043d\u043e.<\/span><\/p>\n<p>06:12<br \/>\n<span style=\"font-weight: 400;\">\u041c\u044b \u0442\u0440\u0430\u0442\u0438\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u0442\u0438\u043f\u0430\u0445, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043e \u0444\u043e\u0440\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041f\u043e\u0440\u043e\u0439 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430: \u0442\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442 \u0438\u0437 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0432\u0441\u0451 \u0437\u0430\u0442\u0443\u043c\u0430\u043d\u0438\u0442\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435-\u043a\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442 \u0441\u0430\u043c\u0438\u0445 \u0442\u0438\u043f\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 \u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432\u0438\u0434\u0430 <strong><span style=\"color: #5c2699;\">(Configuration) -&gt; (Data) -&gt; ReturnValue<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">\/\/ flatMap : ((A) -&gt; [B]) -&gt; ([A]) -&gt; [B]\r\n\/\/ flatMap : ((A) -&gt;  B?) -&gt; ( A?) -&gt;  B?\r\n\r\n\/\/ flatMap : ((A) -&gt;  B?) -&gt; ([A]) -&gt; [B]<\/pre>\n<p>07:24<br \/>\n<span style=\"font-weight: 400;\">\u041e\u0434\u043d\u0430 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0444\u043e\u0440\u043c \u043d\u0435 \u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435. \u0414\u0432\u0430 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 <strong><span style=\"color: #5c2699;\">flatMaps<\/span><\/strong> \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u043d\u0430\u0434 \u043e\u0434\u043d\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430: <strong><span style=\"color: #5c2699;\">Array<\/span><\/strong> \u0438\u043b\u0438 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>, \u0430 \u0432\u043e\u0442 \u0442\u0440\u0435\u0442\u0438\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0434 \u043e\u0431\u043e\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u0441\u0440\u0430\u0437\u0443.<\/span><\/p>\n<p>07:43<br \/>\n<span style=\"font-weight: 400;\">\u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430, \u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0435 (<strong>generics<\/strong>) \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">\/\/ flatMap : ((A) -&gt;    Array&lt;B&gt;) -&gt; (   Array&lt;A&gt;) -&gt;    Array&lt;B&gt;\r\n\/\/ flatMap : ((A) -&gt; Optional&lt;B&gt;) -&gt; (Optional&lt;A&gt;) -&gt; Optional&lt;B&gt;\r\n\r\n\/\/ flatMap : ((A) -&gt; Optional&lt;B&gt;) -&gt; (   Array&lt;A&gt;) -&gt;    Array&lt;B&gt;<\/pre>\n<p>08:00<br \/>\n<span style=\"font-weight: 400;\">\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0442\u0438\u043f\u043e\u0432 <strong><span style=\"color: #5c2699;\">Array<\/span><\/strong> \u0438 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0435 (<strong>generics<\/strong>) \u0442\u0438\u043f\u044b. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">\/\/ flatMap : ((A) -&gt; M&lt;B&gt;) -&gt; (M&lt;A&gt;) -&gt; M&lt;B&gt;\r\n\/\/ flatMap : ((A) -&gt; M&lt;B&gt;) -&gt; (M&lt;A&gt;) -&gt; M&lt;B&gt;\r\n\r\n\/\/ flatMap : ((A) -&gt; N&lt;B&gt;) -&gt; (M&lt;A&gt;) -&gt; M&lt;B&gt;<\/pre>\n<p>08:36<br \/>\n<span style=\"font-weight: 400;\">\u0423\u0445-\u0442\u044b, \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0432\u043d\u044b! \u0410 \u0432\u043e\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u0434\u0432\u0443\u043c\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u043c\u0438 (<strong>generic<\/strong>) \u0442\u0438\u043f\u0430\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 <strong><span style=\"color: #5c2699;\">N<\/span><\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e <strong><span style=\"color: #5c2699;\">M<\/span><\/strong>? \u0412 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0445\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0430\u043a-\u0442\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043b\u0430\u0434. \u0412 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <strong><span style=\"color: #5c2699;\">N<\/span><\/strong> \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.<br \/>\n09:27<br \/>\n\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u0430\u043c.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">\/\/ flatMap : ((A) -&gt; B?) -&gt; (M&lt;A&gt;) -&gt; M&lt;B&gt;<\/pre>\n<p><span style=\"font-weight: 400;\">\u0412\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e. \u041c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043b\u044e\u0431\u043e\u0439 <strong><span style=\"color: #5c2699;\">M<\/span><\/strong> \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c? \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u043e\u0442 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u043c (<strong>generic<\/strong>), \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435.<\/span><\/p>\n<h2>\u041f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0434\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> (Optional promotion)<a id=\"optional_promotion_ref\" href=\"#optional_promotion_note\">[1]<\/a><\/h2>\n<p>10:13<br \/>\n<span style=\"font-weight: 400;\">\u0411\u044b\u043b\u0430 \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u043e\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 <strong><span style=\"color: #5c2699;\">Array<\/span><\/strong>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>: \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0434\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> (Optional promotion). \u0414\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u044d\u0440\u0433\u043e\u043d\u043e\u043c\u0438\u043a\u0438 <strong>Swift<\/strong> \u0432 \u043a\u043e\u0434\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u201c\u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u201d \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<a id=\"optional_parameter_ref\" href=\"#optional_parameter_note\">[2]<\/a> \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c \u0438 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u042f\u0412\u041d\u041e \u201c\u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u201d \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><span style=\"color: #5c2699;\">.some<\/span><\/strong>, \u043d\u043e \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (inference) &#8212; \u044d\u0442\u043e \u043f\u0430\u043b\u043a\u0430 \u043e \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0446\u0430\u0445, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435\u043c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u043c <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u044d\u0442\u043e &#8212; \u0447\u0435\u0441\u0442\u043d\u0430\u044f \u0438\u0433\u0440\u0430.<br \/>\n10:54<br \/>\n<span style=\"font-weight: 400;\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043d\u0438\u043f\u043f\u0435\u0442:<\/span><\/span><\/p>\n<pre class=\"lang:swift decode:true\">[1, 2, 3]\r\n  .flatMap { $0 + 1 }\r\n\/\/ [2, 3, 4]<\/pre>\n<p><span style=\"font-weight: 400;\">\u041e\u043d \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0432\u044b\u0434\u0430\u0451\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u043e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u0430\u044f: \u043c\u044b \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0438\u0437 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u201c\u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u201d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0434\u0435\u043b\u0430\u044f \u044d\u0442\u043e \u0437\u0430 \u043d\u0430\u0441, \u0432\u043e\u0442 \u0442\u0430\u043a.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">[1, 2, 3]\r\n  .flatMap { .some($0 + 1) }\r\n\/\/ [2, 3, 4]<\/pre>\n<p>11:22<br \/>\n<span style=\"font-weight: 400;\">\u201c\u0417\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435\u201d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u043e \u0432\u0441\u0435\u0439 \u043b\u043e\u0433\u0438\u043a\u0435. \u041c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <strong><span style=\"color: #5c2699;\">.some<\/span><\/strong> \u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u00ab\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f\u00bb \u0434\u043e <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>. \u0418 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u041d\u0418\u041a\u041e\u0413\u0414\u0410 \u043d\u0438 \u043f\u0440\u0438 \u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u0445 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u00ab\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f\u00bb, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<strong> <span style=\"color: #5c2699;\">map<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">[1, 2, 3]\r\n  .map { $0 + 1 }\r\n\/\/ [2, 3, 4]<\/pre>\n<p>11:36<br \/>\n<span style=\"font-weight: 400;\">\u0418\u0437-\u0437\u0430 \u201c\u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e Optional\u201d (Optional promotion) \u043b\u044e\u0431\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u0441 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0441 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>. \u041c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043c\u0430\u043d\u0447\u0438\u0432\u044b\u043c \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <strong><span style=\"color: #5c2699;\">map<\/span><\/strong>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <strong><span style=\"color: #5c2699;\">map<\/span><\/strong>\u00a0\u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042d\u0442\u043e \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0438\u0441\u043a\u043e\u0440\u0431\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0442\u0435\u0440\u044f\u0435\u043c \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u0432\u0441\u044e\u0434\u0443 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u0430\u043a <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u0442\u0430\u043a \u0438 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong>, \u043c\u044b \u043a\u0430\u043a \u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u042f\u0412\u041d\u041e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442, \u0430 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u00ab\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f\u00bb (<strong>fail<\/strong>).<\/span><\/p>\n<p>12:08<br \/>\n<span style=\"font-weight: 400;\">\u0427\u0442\u043e \u0435\u0449\u0451 \u0445\u0443\u0436\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0438\u043f\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0438\u0437-\u0437\u0430 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0433\u043e (<strong>overloaded<\/strong>) <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> (Optional promotion) \u0432\u0441\u0451 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <strong><span style=\"color: #5c2699;\">User<\/span><\/strong>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0438\u043c\u0435\u043d\u0435\u043c <strong><span style=\"color: #5c2699;\">name<\/span><\/strong>, \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <strong><span style=\"color: #5c2699;\">users<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">struct User {\r\n  let name: String?\r\n}\r\n\r\nlet users = [User(name: \"Blob\"), User(name: \"Math\")]<\/pre>\n<p>12:15<br \/>\n<span style=\"font-weight: 400;\">\u0421 \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <strong><span style=\"color: #5c2699;\">users<\/span><\/strong>\u00a0\u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u043b\u0430\u0437\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0438\u043c\u0435\u043d <strong><span style=\"color: #5c2699;\">names<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">users\r\n  .map { $0.name }\r\n\/\/ [{some \"Blob\"}, {some \"Math\"}]<\/pre>\n<p><span style=\"font-weight: 400;\">\u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043c\u0430\u0441\u0441\u0438\u0432 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">users\r\n  .flatMap { $0.name }\r\n\/\/ [\"Blob\", \"Math\"]<\/pre>\n<p>12:32<br \/>\n<span style=\"font-weight: 400;\">\u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u0438\u043f\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 <strong><span style=\"color: #5c2699;\">struct User<\/span><\/strong>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0440\u0435\u0448\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u044f <strong><span style=\"color: #5c2699;\">name<\/span><\/strong> \u0432 \u0442\u0438\u043f\u0435 <strong><span style=\"color: #5c2699;\">User<\/span><\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041c\u044b \u0432\u044b\u0440\u043e\u0441\u043b\u0438 \u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0449\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u043c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043a\u043e\u0434\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043a\u0440\u0443\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u0442\u0438\u043f, [\u0430 \u0442\u0443\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u044e\u0440\u043f\u0440\u0438\u0437].<\/span><\/p>\n<pre class=\"lang:swift decode:true \">struct User {\r\n  let name: String\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438?<\/span><\/p>\n<pre class=\"lang:swift decode:true \">users\r\n  .flatMap { $0.name }\r\n\/\/ [\"B\", \"l\", \"o\", \"b\", \"M\", \"a\", \"t\", \"h\"]<\/pre>\n<p><span style=\"font-weight: 400;\">\u041e\u043d\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0435! \u041c\u043e\u0436\u0435\u0442 \u0438 \u043a \u043b\u0443\u0447\u0448\u0435\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0430.<\/span><\/p>\n<h2>compactMap \u0438 filterMap<\/h2>\n<p>13:18<br \/>\n<span style=\"font-weight: 400;\">\u0418\u0442\u0430\u043a, \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c (<strong>overloaded<\/strong>) <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0430\u043a\u0438\u043c, \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435 <strong><span style=\"color: #5c2699;\">flatMaps<\/span><\/strong>, \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f. \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043d\u0430\u0434 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0441 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\u043c\u0438, \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0438 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u043d\u0430\u0434 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <strong><span style=\"color: #5c2699;\">Optionals<\/span><\/strong>, \u043d\u0435 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0435\u043d\u044b. \u0420\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043b\u0438\u0448\u044c \u043e\u0431 \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u043e\u043c (\u0442\u0440\u0435\u0442\u044c\u0435\u043c) \u043c\u0435\u0442\u043e\u0434\u0435.<\/span><\/p>\n<p>13:48<br \/>\n<span style=\"font-weight: 400;\">\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0438\u043c\u044f <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong> \u0434\u043b\u044f \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f (<strong>mapping<\/strong>) \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>. \u042d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u0442\u0430\u043a:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">extension Array {\r\n  func filterMap&lt;B&gt;(_ transform: (Element) -&gt; B?) -&gt; [B] {\r\n    var result = [B]()\r\n    for x in self {\r\n      switch transform(x) {\r\n      case let .some(x):\r\n        result.append(x)\r\n      case let .none:\r\n        continue\r\n      }\r\n    }\r\n    return result\r\n  }\r\n}<\/pre>\n<p>14:29<br \/>\n<span style=\"font-weight: 400;\">\u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u00ab\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e\u0433\u043e \u0441\u0430\u0440\u0430\u044f\u00bb, \u0441\u0442\u0430\u0432\u0448\u0438\u0439 \u043c\u0435\u0442\u0430\u0444\u043e\u0440\u043e\u0439 \u0437\u0430\u043a\u043e\u043d\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0441 \u0432\u043e\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 Swift Evolution, \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e\u0433\u043e \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong>, \u0438 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0443 \u0432 Ruby, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <strong><span style=\"color: #5c2699;\">compact<\/span><\/strong> \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438, \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">extension Array {\r\n  func compactMap&lt;B&gt;(_ transform: (Element) -&gt; B?) -&gt; [B] {\r\n    var result = [B]()\r\n    for x in self {\r\n      switch transform(x) {\r\n      case let .some(x):\r\n        result.append(x)\r\n      case let .none:\r\n        continue\r\n      }\r\n    }\r\n    return result\r\n  }\r\n}<\/pre>\n<p>14:53<br \/>\n<span style=\"font-weight: 400;\">\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435.<\/span><\/p>\n<h2>\u041e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f (generalizations) filterMap<\/h2>\n<p>15:06<br \/>\n<span style=\"font-weight: 400;\">\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u0438\u043c\u0435\u043d\u0438 <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u043a\u0440\u0435\u043f\u043a\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c: \u043c\u044b \u00ab\u0441\u0436\u0438\u043c\u0430\u0435\u043c\u00bb \u0435\u0433\u043e \u043f\u0443\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f <strong><span style=\"color: #5c2699;\">nils<\/span><\/strong>. \u042d\u0442\u043e \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong>.<\/span><\/p>\n<p>15:30<br \/>\n<span style=\"font-weight: 400;\">\u0410 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u043c\u0435\u043d\u0438 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0434\u0430\u0447\u043d\u044b\u043c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c.<\/span><\/p>\n<p>15:41<br \/>\n<span style=\"font-weight: 400;\">\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 <strong><span style=\"color: #5c2699;\">(A) -&gt; Bool<\/span><\/strong> \u043d\u0430\u0434 <strong><span style=\"color: #5c2699;\">A<\/span><\/strong> \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><span style=\"color: #5c2699;\">(A) -&gt; A?<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">func filterSome&lt;A&gt;(_ p: @escaping (A) -&gt; Bool) -&gt; (A) -&gt; A? {\r\n  return { p($0) ? .some($0) : .none }\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">\u041e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong><span style=\"color: #5c2699;\">.some<\/span><\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0440\u0430\u0432\u0435\u043d <strong><span style=\"color: #5c2699;\">true<\/span><\/strong>, \u0438 <strong><span style=\"color: #5c2699;\">.none<\/span><\/strong> \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/span><\/p>\n<p>16:33<br \/>\n<span style=\"font-weight: 400;\">\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043d\u043e\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 OEM <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u043d\u0430\u0434 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">func filter&lt;A&gt;(_ p: @escaping (A) -&gt; Bool) -&gt; ([A]) -&gt; [A] {\r\n  return { $0.filterMap(filterSome(p)) }\r\n}<\/pre>\n<p>16:41<br \/>\n<span style=\"font-weight: 400;\">\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f \u0447\u0451\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">filter { $0 % 2 == 0 }\r\n\/\/ ([Int]) -&gt; [Int]<\/pre>\n<p><span style=\"font-weight: 400;\">\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0432\u043e\u0437\u044c \u043d\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0435\u0441\u044f\u0442\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b [\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong>pipeline<\/strong> \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">|&gt;<\/span><\/strong>].<\/span><\/p>\n<pre class=\"lang:swift decode:true \">Array(0..&lt;10)\r\n  |&gt; filter { $0 % 2 == 0 }\r\n\/\/ [2, 4, 6, 8, 10]<\/pre>\n<p>16:51<\/p>\n<p><span style=\"font-weight: 400;\">\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u043e \u0442\u0430\u043a \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u041c\u044b \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041f\u0440\u0438\u0447\u0438\u043d\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u043c \u0431\u044b \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0441 \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c.<\/span><\/p>\n<p>17:08<\/p>\n<p><span style=\"font-weight: 400;\">\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u00a0<strong><a href=\"https:\/\/www.pointfree.co\/episodes\/ep4-algebraic-data-types\" target=\"_blank\" rel=\"noopener\">\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c<\/a><\/strong>, \u0447\u0442\u043e <strong><span style=\"color: #5c2699;\">Either&lt;A, B&gt;<\/span><\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c <strong><span style=\"color: #5c2699;\">Optional&lt;A&gt;<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">enum Either&lt;A, B&gt; {\r\n  case left(A)\r\n  case right(B)\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">\u0412\u043c\u0435\u0441\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f <strong><span style=\"color: #5c2699;\">A<\/span><\/strong> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <strong><span style=\"color: #5c2699;\">nil<\/span><\/strong>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u0442\u0438\u043f\u043e\u043c <strong><span style=\"color: #5c2699;\">B<\/span><\/strong> \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e.<\/span><\/p>\n<p>17:31<\/p>\n<p><span style=\"font-weight: 400;\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f <strong><span style=\"color: #5c2699;\">filterSome<\/span><\/strong> \u0434\u043b\u044f <strong><span style=\"color: #5c2699;\">Either<\/span><\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u0431\u044b \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func partitionEither&lt;A&gt;(_ p: @escaping (A) -&gt; Bool) -&gt; (A) -&gt; Either&lt;A, A&gt; {\r\n  return { p($0) ? .right($0) : .left($0) }\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">\u0414\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 <strong><span style=\"color: #5c2699;\">(A) -&gt; Bool<\/span><\/strong>, \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 <strong><span style=\"color: #5c2699;\">(A)<\/span><\/strong> \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u0432\u0443\u0445 case <strong><span style=\"color: #5c2699;\">Either&lt;A, A&gt;<\/span><\/strong>.<\/span><\/p>\n<p>18:08<\/p>\n<p><span style=\"font-weight: 400;\">\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u043e\u0431\u0449\u0438\u043c <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0443 \u0441\u0432\u044f\u0437\u043a\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 <strong><span style=\"color: #5c2699;\">Either<\/span><\/strong>, \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">extension Array {\r\n  func partitionMap&lt;A, B&gt;(_ transform: (Element) -&gt; Either&lt;A, B&gt;) -&gt; (lefts: [A], rights: [B]) {\r\n    var result = (lefts: [A](), rights: [B]())\r\n    for x in self {\r\n      switch transform(x) {\r\n      case let .left(a):\r\n        result.lefts.append(a)\r\n      case let .right(b):\r\n        result.rights.append(b)\r\n      }\r\n    }\r\n    return result\r\n  }\r\n}<\/pre>\n<p>19:17<\/p>\n<p><span style=\"font-weight: 400;\">\u041c\u044b \u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u0438\u0437 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong>. \u041c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 <strong><span style=\"color: #5c2699;\">partition<\/span><\/strong> \u0438\u0437 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>?<\/span><\/p>\n<pre class=\"lang:swift decode:true \">func partition&lt;A&gt;(_ p: @escaping (A) -&gt; Bool) -&gt; ([A]) -&gt; (`false`: [A], `true`: [A]) {\r\n  return { $0.partitionMap(partitionEither(p)) } \/\/ error\r\n}<\/pre>\n<p>20:09<\/p>\n<p><span style=\"font-weight: 400;\">\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0434\u0435\u0441\u044c \u0441\u043b\u0435\u0433\u043a\u0430 \u0441\u043f\u043e\u0442\u044b\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u0438 \u0441\u043e\u0431\u0440\u0430\u0432 \u0437\u0430\u043d\u043e\u0432\u043e.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">func partition&lt;A&gt;(_ p: @escaping (A) -&gt; Bool) -&gt; ([A]) -&gt; (`false`: [A], `true`: [A]) {\r\n  return {\r\n    let (lefts, rights) = $0.partitionMap(partitionEither(p))\r\n    return (lefts, rights)\r\n  }\r\n}<\/pre>\n<p>20:28<\/p>\n<p><span style=\"font-weight: 400;\">\u042d\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u0435\u0434\u044c \u00a0<strong><span style=\"color: #5c2699;\">partition<\/span><\/strong> \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u0430 \u043d\u0430\u0441 \u043a \u043d\u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0432\u0435\u043b\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u0438 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u043a <strong><span style=\"color: #5c2699;\">Either<\/span><\/strong>.<\/span><\/p>\n<p>20:51<\/p>\n<p><span style=\"font-weight: 400;\">\u0418\u0442\u0430\u043a, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u0437\u0434\u0435\u0441\u044c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\"><a href=\"https:\/\/habr.com\/post\/310172\/\" target=\"_blank\" rel=\"noopener\"><strong>\u041f\u043e\u0434\u044a\u0451\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430<\/strong><\/a> <strong><span style=\"color: #5c2699;\">(A) -&gt; Bool<\/span><\/strong> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432 <strong><span style=\"color: #5c2699;\">Optionals :\u00a0<strong><span style=\"color: #5c2699;\">(A) -&gt; A?<\/span><\/strong> \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438\u0432\u0435\u043b \u043d\u0430\u0441 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0443\u044e \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong>.<\/span><\/strong><\/span><\/li>\n<li><span style=\"font-weight: 400;\"><a href=\"https:\/\/habr.com\/post\/310172\/\" target=\"_blank\" rel=\"noopener\"><strong>\u041f\u043e\u0434\u044a\u0451\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430<\/strong><\/a> <strong><span style=\"color: #5c2699;\">(A) -&gt; Bool<\/span><\/strong> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432 <strong><span style=\"color: #5c2699;\">Either<\/span><\/strong> : \u00a0<strong><span style=\"color: #5c2699;\">(A) -&gt; Either&lt;A, A&gt;<\/span><\/strong> \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438\u0432\u0435\u043b \u043d\u0430\u0441 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><span style=\"color: #5c2699;\">partition<\/span><\/strong>.<\/span><\/li>\n<\/ul>\n<p>21:17<\/p>\n<p><span style=\"font-weight: 400;\">\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u0440\u043e\u0447\u0438\u043c\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c\u0438, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u043c\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u043f\u0438\u0437\u043e\u0434\u0430\u0445, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\u043c\u0438 (<strong><a href=\"https:\/\/www.pointfree.co\/episodes\/ep6-functional-setters\" target=\"_blank\" rel=\"noopener\">functional setters<\/a><\/strong>). \u041c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0435 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (<strong>setters<\/strong>), \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0441\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 (free functions &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043d\u0438 \u043a \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441\u0443, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044e), \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>:<\/span><\/p>\n<pre class=\"lang:swift decode:true \">func partitionMap&lt;A, B, C&gt;(_ p: @escaping (A) -&gt; Either&lt;B, C&gt;) -&gt; ([A]) -&gt; (lefts: [B], rights: [C]) {\r\n  return { $0.partitionMap(p) }\r\n}<\/pre>\n<p>21:36<\/p>\n<p><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong><\/span><\/p>\n<pre class=\"lang:swift decode:true \">let evenOdds = { $0 % 2 == 0 ? Either.left($0) : .right($0) }\r\n\/\/ (Int) -&gt; Either&lt;Int, Int&gt;<\/pre>\n<p>21:48<\/p>\n<p><span style=\"font-weight: 400;\">\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0440\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u043e\u0442 \u044d\u0442\u043e\u043c\u0443 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">partitionMap(evenOdds)\r\n\/\/ ([Int]) -&gt; (lefts: [Int], rights: [Int])<\/pre>\n<p><span style=\"font-weight: 400;\">\u0418 \u0432\u043e\u0442 \u0443\u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0435\u0440\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0430 \u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 (tuple), \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443: \u0447\u0451\u0442\u043d\u044b\u0435 &#8212; \u00ab\u043d\u0430\u043b\u0435\u0432\u043e\u00bb, \u043d\u0435\u0447\u0451\u0442\u043d\u044b\u0435 &#8212; \u00ab\u043d\u0430\u043f\u0440\u0430\u0432\u043e\u00bb.<\/span><\/p>\n<p>21:57<\/p>\n<p><span style=\"font-weight: 400;\">\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">Array(1...10)\r\n  |&gt; partitionMap(evenOdds)\r\n\/\/ ([2, 4, 6, 8, 10], [1, 3, 5, 7, 9])<\/pre>\n<p><a id=\"pipeline_ref\" href=\"#pipeline_note\">[3]<\/a><span style=\"font-weight: 400;\">\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c.<br \/>\n<\/span><br \/>\n<span style=\"font-weight: 400;\">\u041c\u044b \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u0430\u0448\u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 (<strong><a href=\"https:\/\/www.pointfree.co\/episodes\/ep6-functional-setters\" target=\"_blank\" rel=\"noopener\">tuple composable setters<\/a><\/strong>). \u041f\u043e\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435 \u0432 \u0447\u0451\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0432\u043e\u0437\u0432\u0435\u0434\u0451\u043c \u0438\u0445 \u0432\u0441\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442.<\/span><\/p>\n<pre class=\"lang:swift decode:true \">Array(1...10)\r\n  |&gt; partitionMap(evenOdds)\r\n  |&gt; (first &lt;&lt;&lt; map)(square)\r\n\/\/ ([4, 16, 36, 64, 100], [1, 3, 5, 7, 9])<\/pre>\n<p>22:21<\/p>\n<p><span style=\"font-weight: 400;\">\u0412\u0441\u0435\u0433\u043e \u0432 \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u043f\u0440\u043e\u0447\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<br \/>\n<\/span><a id=\"free_functions_ref\" href=\"#free_functions_note\">[4]<\/a><\/p>\n<h2>\u0412 \u0447\u0451\u043c \u0441\u043c\u044b\u0441\u043b?<\/h2>\n<p><span style=\"font-weight: 400;\">\u041c\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0439 \u044d\u043f\u0438\u0437\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u044b \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0442\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \u00ab\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e\u0433\u043e \u0441\u0430\u0440\u0430\u044f\u00bb [\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0443 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u041f\u0430\u0440\u043a\u0438\u043d\u0441\u043e\u043d\u0430], \u043a\u0430\u043a \u044d\u0442\u043e \u0438 \u0432\u044b\u0448\u043b\u043e \u0441 \u00a0<strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u0442\u044c: \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u043b\u043e \u043b\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e? \u0423\u043f\u0440\u0430\u0437\u0434\u043d\u0435\u043d\u0438\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0442\u0440\u044f\u0445\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u041b\u044e\u0434\u0438 \u0432 \u0441\u0432\u043e\u0451\u043c \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u043c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0431\u044b\u043b\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0432 Swift 4.1, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: \u00ab\u0412 \u0447\u0451\u043c \u0441\u043c\u044b\u0441\u043b?\u00bb \u0421\u0442\u043e\u0438\u043b\u043e \u043b\u0438 \u043e\u0431\u0440\u0435\u043a\u0430\u0442\u044c \u043b\u044e\u0434\u0435\u0439 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u043a\u0438 \u0440\u0430\u0434\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f.<\/span><\/p>\n<p>23:24<\/p>\n<p><span style=\"font-weight: 400;\">\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0448\u0430\u0433 \u043d\u0430\u0437\u0430\u0434 \u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0432\u0435\u0449\u0438 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0413\u043b\u044f\u0434\u044f \u043b\u0438\u0448\u044c \u043d\u0430 \u0444\u043e\u0440\u043c\u044b <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong>, \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0435\u0439, \u0438 \u043a\u0430\u043a \u0434\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 <strong><span style=\"color: #5c2699;\">flatMaps<\/span><\/strong> \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/span><\/p>\n<p>23:53<\/p>\n<p><span style=\"font-weight: 400;\">\u0422\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438 \u0432 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438 \u043d\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/span><\/p>\n<p>24:09<\/p>\n<p><span style=\"font-weight: 400;\">\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043f\u043e\u0440\u043d\u044b\u043c! \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0438\u043c\u0435\u043d\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0447\u043d\u044b\u0435 \u0443\u0437\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0446\u0435\u043d\u0446\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0441 \u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f\u043c: \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043a\u0430\u043a <strong><span style=\"color: #5c2699;\">filter<\/span><\/strong> \u0438 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong> \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043d\u0430\u0441 \u043a <strong><span style=\"color: #5c2699;\">partition<\/span><\/strong> \u0438 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>!<\/span><\/p>\n<p>24:28<\/p>\n<p><span style=\"font-weight: 400;\">\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0439 <strong><span style=\"color: #5c2699;\">flatMap<\/span><\/strong> \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d \u0432 <strong><span style=\"color: #5c2699;\">compactMap<\/span><\/strong>, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0442\u0438\u043f\u0430\u0445 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/span><\/p>\n<hr \/>\n<h2>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f<\/h2>\n<ol>\n<li><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">filtered<\/span><\/strong> \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 <strong><span style=\"color: #5c2699;\">[A?]<\/span><\/strong> \u043a <strong><span style=\"color: #5c2699;\">[A]<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">partitioned<\/span><\/strong> \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 <strong><span style=\"color: #5c2699;\">[Either&lt;A, B&gt;]<\/span><\/strong> \u043a <strong><span style=\"color: #5c2699;\">(left: [A], right: [B])<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u0427\u0442\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0443 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 <strong><span style=\"color: #5c2699;\">filtered<\/span><\/strong>?<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong> \u043d\u0430 <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u0423 \u0441\u043b\u043e\u0432\u0430\u0440\u044f <strong><span style=\"color: #5c2699;\">Dictionary<\/span><\/strong> \u0435\u0441\u0442\u044c <strong><span style=\"color: #5c2699;\">mapValues<\/span><\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0435\u0440\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 \u00a0<strong><span style=\"color: #5c2699;\">(Value) -&gt;<\/span><\/strong> B \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f <strong><span style=\"color: #5c2699;\">Dictionary<\/span><\/strong> \u0442\u0438\u043f\u0430 \u00a0<strong><span style=\"color: #5c2699;\">[Key: B]<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">filterMapValues<\/span><\/strong> \u043d\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <strong><span style=\"color: #5c2699;\">Dictionary<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">partitionMapValues<\/span><\/strong> \u043d\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u00a0<strong><span style=\"color: #5c2699;\">Dictionary<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0438\u0442\u0435 <strong><span style=\"color: #5c2699;\">filterMap<\/span><\/strong> \u0438 <strong><span style=\"color: #5c2699;\">filte<\/span><\/strong> \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong>.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong> \u043d\u0430 <strong><span style=\"color: #5c2699;\">Either<\/span><\/strong>?<\/span><\/li>\n<\/ol>\n<hr \/>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a href=\"https:\/\/www.pointfree.co\/episodes\/ep10-a-tale-of-two-flat-maps\">A Tale of Two flatMaps<\/a><br \/>\n\u041a\u043e\u0434: <a href=\"https:\/\/github.com\/Mrteller\/FilterMap.playground\">Playground \u043a \u0441\u0442\u0430\u0442\u044c\u0435<\/a><br \/>\n\u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043e <a href=\"https:\/\/laconic.website\">Laconic.Website<\/a> \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Bestkora<\/p>\n<hr \/>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/h2>\n<p><a id=\"optional_promotion_note\" href=\"#optional_promotion_ref\">[1\u21d1]<\/a><span style=\"font-weight: 400;\"><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430.<\/em> \u0422\u0435\u0440\u043c\u0438\u043d \u041f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0434\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> (Optional promotion) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u00bb \u041d\u0415-<strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0434\u043e <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong> \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <strong><span style=\"color: #5c2699;\">Optional<\/span><\/strong>.<\/span><\/p>\n<p><a id=\"optional_parameter_note\" href=\"#optional_parameter_ref\">[2\u21d1]<\/a><span style=\"font-weight: 400;\"><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/em>. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/span><\/p>\n<p><a id=\"pipeline_note\" href=\"#pipeline_ref\">[3\u21d1]<\/a><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/em>. \u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 pipeline \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f <strong><span style=\"color: #5c2699;\">|&gt;<\/span><\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u201c\u0446\u0435\u043f\u043e\u0447\u043a\u0443\u201d \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0445\u043e\u0434\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439. \u0412\u043e\u0442 \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Swift:<\/p>\n<pre class=\"lang:swift decode:true\">precedencegroup ForwardApplication {\r\n   associativity: left }\r\n\r\nInfix operator |&gt;: ForwardApplication\r\npublic func |&gt; &lt;A,B&gt;(x: A, f: (A) -&gt;B) -&gt; B {\r\nreturn f(x)\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 pipeline \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">|&gt;<\/span><\/strong> \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b <strong><span style=\"color: #5c2699;\">Array(1&#8230;10)<\/span><\/strong> \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong> \u0434\u043b\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0442\u043d\u044b\u0445 \u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/span><\/p>\n<p><a id=\"free_functions_note\" href=\"#free_functions_ref\">[4\u21d1]<\/a><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/em>. \u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">first<\/span><\/strong> (\u0432\u0437\u044f\u0442\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043d\u0435\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438), <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, <strong><span style=\"color: #5c2699;\">square<\/span><\/strong> \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 <strong><span style=\"color: #5c2699;\">&lt;&lt;&lt;<\/span><\/strong>.<\/p>\n<p><span style=\"font-weight: 400;\">\u0412\u043e\u0442 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 <strong>Swift,<\/strong> \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func first&lt;A, B, C&gt;(_f: @escappng (A) -&gt; C) -&gt; ((A,B)) -&gt; (C,B) {\r\nreturn { pair in\r\n(f(pair.0), pair.1)\r\n}\r\n}\r\n\r\n func map&lt;A, B&gt;(_f: @escappng (A) -&gt; B) -&gt; ([A]) -&gt; [B] {\r\nreturn { $0.map(f) }\r\n}\r\n\r\n public func square(_x: Int) -&gt; Int{\r\nreturn x * x\r\n}\r\n\r\nprecedencegroup BackwardsComposion {\r\n   associativity: left }\r\n\r\nInfix operator &lt;&lt;&lt;: BackwardsComposion\r\npublic func &lt;&lt;&lt; &lt;A, B, C&gt;(\r\n_f: @escaping (B) -&gt;C,\r\n_g: @escaping (A) -&gt;B,\r\n) -&gt; (A)  -&gt; C {\r\nreturn f(g($0))\r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043e\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 <strong>pipeline<\/strong> \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">|&gt;<\/span><\/strong> \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b <strong><span style=\"color: #5c2699;\">Array(1&#8230;10)<\/span><\/strong> \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong><span style=\"color: #5c2699;\">partitionMap<\/span><\/strong> \u0434\u043b\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0442\u043d\u044b\u0445 \u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>setter<\/strong> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0433\u043b\u0443\u0431\u0436\u0435 \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430), \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <strong><span style=\"color: #5c2699;\">map<\/span><\/strong> \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 <strong><span style=\"color: #5c2699;\">square<\/span><\/strong> (\u043a\u0432\u0430\u0434\u0440\u0430\u0442).<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swift \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0442\u0430\u0447\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438 \u043d\u0430 Objective-C \u0438 \u0432\u043e\u0448\u043b\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0432 Swift (\u0443 Objective-C \u0438 Swift \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 SDK), \u0442\u043e \u0447\u0430\u0441\u0442\u044c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043d\u0438, \u0438\u0437\u0440\u0435\u0434\u043a\u0430 &#171;\u043f\u043e\u0431\u043b\u0435\u0441\u043a\u0438\u0432\u0430\u044f&#187; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 &hellip; <a href=\"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,49],"tags":[],"class_list":["post-9813","post","type-post","status-publish","format-standard","hentry","category-swift-4","category-stati"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Pavel\"\/>\n\t<meta name=\"keywords\" content=\"swift 4.1,flatmap,compactmap,partitionmap\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"ru_RU\" \/>\n\t\t<meta property=\"og:site_name\" content=\"\u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. | \u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442 \u043b\u0435\u043a\u0446\u0438\u0439 \u0421\u0442\u044d\u043d\u0444\u043e\u0440\u0434\u0441\u043a\u043e\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430 &quot; \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 iOS \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439&quot; 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 , 2023,  2024,  2025  \u0438 2026 \u0433\u0433., \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u0443\u0440\u0441\u043e\u0432 \u043a \u043d\u043e\u0432\u044b\u043c \u0432\u0435\u0440\u0441\u0438\u044f\u043c Swift, Objective-C \u0438 iOS.\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.\" \/>\n\t\t<meta property=\"og:description\" content=\"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-07-11T20:52:36+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-12-01T14:04:13+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#article\",\"name\":\"\\u0421\\u043a\\u0430\\u0437 \\u043e \\u0442\\u043e\\u043c \\u043a\\u0430\\u043a \\u043e\\u0434\\u0438\\u043d \\u0438\\u0437 flatMap \\u043f\\u0440\\u0435\\u0432\\u0440\\u0430\\u0442\\u0438\\u043b\\u0441\\u044f \\u0432 compactMap | \\u041e\\u0431\\u0443\\u0447\\u0430\\u044e\\u0449\\u0438\\u0439 \\u043a\\u0443\\u0440\\u0441 \\u043f\\u043e \\u0440\\u0430\\u0437\\u0440\\u0430\\u0431\\u043e\\u0442\\u043a\\u0435 iOS+Swift \\u043f\\u0440\\u0438\\u043b\\u043e\\u0436\\u0435\\u043d\\u0438\\u0439.\",\"headline\":\"\\u0421\\u043a\\u0430\\u0437 \\u043e \\u0442\\u043e\\u043c \\u043a\\u0430\\u043a \\u043e\\u0434\\u0438\\u043d \\u0438\\u0437 flatMap \\u043f\\u0440\\u0435\\u0432\\u0440\\u0430\\u0442\\u0438\\u043b\\u0441\\u044f \\u0432 compactMap\",\"author\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/author\\\/pavel\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#articleImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8a3cde9bb6344f275196f84045252bf02625911af6b464dc6b3e067a09c01877?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Pavel\"},\"datePublished\":\"2018-07-11T20:52:36+00:00\",\"dateModified\":\"2018-12-01T14:04:13+00:00\",\"inLanguage\":\"ru-RU\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#webpage\"},\"articleSection\":\"Swift 4, \\u0421\\u0442\\u0430\\u0442\\u044c\\u0438\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/category\\\/swift-4\\\/#listItem\",\"name\":\"Swift 4\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/category\\\/swift-4\\\/#listItem\",\"position\":2,\"name\":\"Swift 4\",\"item\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/category\\\/swift-4\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#listItem\",\"name\":\"\\u0421\\u043a\\u0430\\u0437 \\u043e \\u0442\\u043e\\u043c \\u043a\\u0430\\u043a \\u043e\\u0434\\u0438\\u043d \\u0438\\u0437 flatMap \\u043f\\u0440\\u0435\\u0432\\u0440\\u0430\\u0442\\u0438\\u043b\\u0441\\u044f \\u0432 compactMap\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#listItem\",\"position\":3,\"name\":\"\\u0421\\u043a\\u0430\\u0437 \\u043e \\u0442\\u043e\\u043c \\u043a\\u0430\\u043a \\u043e\\u0434\\u0438\\u043d \\u0438\\u0437 flatMap \\u043f\\u0440\\u0435\\u0432\\u0440\\u0430\\u0442\\u0438\\u043b\\u0441\\u044f \\u0432 compactMap\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/category\\\/swift-4\\\/#listItem\",\"name\":\"Swift 4\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/#person\",\"name\":\"tatiana.kornilova@gmail.com\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/33ccc19059014d8a7849c3621afa2b66a5f3e50ac7291c91c30ff35df5747628?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"tatiana.kornilova@gmail.com\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/author\\\/pavel\\\/#author\",\"url\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/author\\\/pavel\\\/\",\"name\":\"Pavel\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8a3cde9bb6344f275196f84045252bf02625911af6b464dc6b3e067a09c01877?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Pavel\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#webpage\",\"url\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/\",\"name\":\"\\u0421\\u043a\\u0430\\u0437 \\u043e \\u0442\\u043e\\u043c \\u043a\\u0430\\u043a \\u043e\\u0434\\u0438\\u043d \\u0438\\u0437 flatMap \\u043f\\u0440\\u0435\\u0432\\u0440\\u0430\\u0442\\u0438\\u043b\\u0441\\u044f \\u0432 compactMap | \\u041e\\u0431\\u0443\\u0447\\u0430\\u044e\\u0449\\u0438\\u0439 \\u043a\\u0443\\u0440\\u0441 \\u043f\\u043e \\u0440\\u0430\\u0437\\u0440\\u0430\\u0431\\u043e\\u0442\\u043a\\u0435 iOS+Swift \\u043f\\u0440\\u0438\\u043b\\u043e\\u0436\\u0435\\u043d\\u0438\\u0439.\",\"description\":\"Swift 4.1 \\u0443\\u043f\\u0440\\u0430\\u0437\\u0434\\u043d\\u0438\\u043b \\u0438 \\u043f\\u0435\\u0440\\u0435\\u0438\\u043c\\u0435\\u043d\\u043e\\u0432\\u0430\\u043b \\u043e\\u043f\\u0440\\u0435\\u0434\\u0435\\u043b\\u0435\\u043d\\u043d\\u0443\\u044e \\u043f\\u0435\\u0440\\u0435\\u0433\\u0440\\u0443\\u0437\\u043a\\u0443 (overload) \\u0444\\u0443\\u043d\\u043a\\u0446\\u0438\\u0438 flatMap. \\u0427\\u0442\\u043e \\u0434\\u0435\\u043b\\u0430\\u0435\\u0442 \\u044d\\u0442\\u043e\\u0442 flatMap \\u043e\\u0442\\u043b\\u0438\\u0447\\u043d\\u044b\\u043c \\u043e\\u0442 \\u0434\\u0440\\u0443\\u0433\\u0438\\u0445?\",\"inLanguage\":\"ru-RU\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/a-tale-of-two-flat-maps\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/author\\\/pavel\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/author\\\/pavel\\\/#author\"},\"datePublished\":\"2018-07-11T20:52:36+00:00\",\"dateModified\":\"2018-12-01T14:04:13+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/#website\",\"url\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/\",\"name\":\"\\u041e\\u0431\\u0443\\u0447\\u0430\\u044e\\u0449\\u0438\\u0439 \\u043a\\u0443\\u0440\\u0441 \\u043f\\u043e \\u0440\\u0430\\u0437\\u0440\\u0430\\u0431\\u043e\\u0442\\u043a\\u0435 iOS+Swift \\u043f\\u0440\\u0438\\u043b\\u043e\\u0436\\u0435\\u043d\\u0438\\u0439.\",\"description\":\"\\u0420\\u0443\\u0441\\u0441\\u043a\\u0438\\u0439 \\u043d\\u0435\\u0430\\u0432\\u0442\\u043e\\u0440\\u0438\\u0437\\u043e\\u0432\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043d\\u0441\\u043f\\u0435\\u043a\\u0442 \\u043b\\u0435\\u043a\\u0446\\u0438\\u0439 \\u0421\\u0442\\u044d\\u043d\\u0444\\u043e\\u0440\\u0434\\u0441\\u043a\\u043e\\u0433\\u043e \\u0443\\u043d\\u0438\\u0432\\u0435\\u0440\\u0441\\u0438\\u0442\\u0435\\u0442\\u0430 \\\" \\u0420\\u0430\\u0437\\u0440\\u0430\\u0431\\u043e\\u0442\\u043a\\u0430 iOS \\u043f\\u0440\\u0438\\u043b\\u043e\\u0436\\u0435\\u043d\\u0438\\u0439\\\" 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 , 2023,  2024,  2025  \\u0438 2026 \\u0433\\u0433., \\u0441\\u043e\\u043f\\u0440\\u043e\\u0432\\u043e\\u0436\\u0434\\u0430\\u0435\\u043c\\u044b\\u0439 \\u0440\\u0435\\u0448\\u0435\\u043d\\u0438\\u044f\\u043c\\u0438 \\u0437\\u0430\\u0434\\u0430\\u043d\\u0438\\u0439 \\u0438 \\u0434\\u043e\\u043f\\u043e\\u043b\\u043d\\u0435\\u043d\\u0438\\u044f\\u043c\\u0438, \\u0441\\u0432\\u044f\\u0437\\u0430\\u043d\\u043d\\u044b\\u043c\\u0438 \\u0441 \\u0430\\u0434\\u0430\\u043f\\u0442\\u0430\\u0446\\u0438\\u0435\\u0439 \\u043a\\u0443\\u0440\\u0441\\u043e\\u0432 \\u043a \\u043d\\u043e\\u0432\\u044b\\u043c \\u0432\\u0435\\u0440\\u0441\\u0438\\u044f\\u043c Swift, Objective-C \\u0438 iOS.\",\"inLanguage\":\"ru-RU\",\"publisher\":{\"@id\":\"https:\\\/\\\/bestkora.com\\\/IosDeveloper\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","description":"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?","canonical_url":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"swift 4.1,flatmap,compactmap,partitionmap","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#article","name":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","headline":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap","author":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/author\/pavel\/#author"},"publisher":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/#person"},"image":{"@type":"ImageObject","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#articleImage","url":"https:\/\/secure.gravatar.com\/avatar\/8a3cde9bb6344f275196f84045252bf02625911af6b464dc6b3e067a09c01877?s=96&d=mm&r=g","width":96,"height":96,"caption":"Pavel"},"datePublished":"2018-07-11T20:52:36+00:00","dateModified":"2018-12-01T14:04:13+00:00","inLanguage":"ru-RU","mainEntityOfPage":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#webpage"},"isPartOf":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#webpage"},"articleSection":"Swift 4, \u0421\u0442\u0430\u0442\u044c\u0438"},{"@type":"BreadcrumbList","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper#listItem","position":1,"name":"Home","item":"https:\/\/bestkora.com\/IosDeveloper","nextItem":{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/#listItem","name":"Swift 4"}},{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/#listItem","position":2,"name":"Swift 4","item":"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/","nextItem":{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#listItem","name":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap"},"previousItem":{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#listItem","position":3,"name":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap","previousItem":{"@type":"ListItem","@id":"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/#listItem","name":"Swift 4"}}]},{"@type":"Person","@id":"https:\/\/bestkora.com\/IosDeveloper\/#person","name":"tatiana.kornilova@gmail.com","image":{"@type":"ImageObject","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/33ccc19059014d8a7849c3621afa2b66a5f3e50ac7291c91c30ff35df5747628?s=96&d=mm&r=g","width":96,"height":96,"caption":"tatiana.kornilova@gmail.com"}},{"@type":"Person","@id":"https:\/\/bestkora.com\/IosDeveloper\/author\/pavel\/#author","url":"https:\/\/bestkora.com\/IosDeveloper\/author\/pavel\/","name":"Pavel","image":{"@type":"ImageObject","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/8a3cde9bb6344f275196f84045252bf02625911af6b464dc6b3e067a09c01877?s=96&d=mm&r=g","width":96,"height":96,"caption":"Pavel"}},{"@type":"WebPage","@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#webpage","url":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/","name":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","description":"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?","inLanguage":"ru-RU","isPartOf":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/#website"},"breadcrumb":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/#breadcrumblist"},"author":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/author\/pavel\/#author"},"creator":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/author\/pavel\/#author"},"datePublished":"2018-07-11T20:52:36+00:00","dateModified":"2018-12-01T14:04:13+00:00"},{"@type":"WebSite","@id":"https:\/\/bestkora.com\/IosDeveloper\/#website","url":"https:\/\/bestkora.com\/IosDeveloper\/","name":"\u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","description":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442 \u043b\u0435\u043a\u0446\u0438\u0439 \u0421\u0442\u044d\u043d\u0444\u043e\u0440\u0434\u0441\u043a\u043e\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430 \" \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 iOS \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439\" 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 , 2023,  2024,  2025  \u0438 2026 \u0433\u0433., \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u0443\u0440\u0441\u043e\u0432 \u043a \u043d\u043e\u0432\u044b\u043c \u0432\u0435\u0440\u0441\u0438\u044f\u043c Swift, Objective-C \u0438 iOS.","inLanguage":"ru-RU","publisher":{"@id":"https:\/\/bestkora.com\/IosDeveloper\/#person"}}]},"og:locale":"ru_RU","og:site_name":"\u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. | \u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442 \u043b\u0435\u043a\u0446\u0438\u0439 \u0421\u0442\u044d\u043d\u0444\u043e\u0440\u0434\u0441\u043a\u043e\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430 &quot; \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 iOS \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439&quot; 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 , 2023,  2024,  2025  \u0438 2026 \u0433\u0433., \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u0443\u0440\u0441\u043e\u0432 \u043a \u043d\u043e\u0432\u044b\u043c \u0432\u0435\u0440\u0441\u0438\u044f\u043c Swift, Objective-C \u0438 iOS.","og:type":"article","og:title":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","og:description":"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?","og:url":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/","article:published_time":"2018-07-11T20:52:36+00:00","article:modified_time":"2018-12-01T14:04:13+00:00","twitter:card":"summary","twitter:title":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043a\u0443\u0440\u0441 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 iOS+Swift \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.","twitter:description":"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?"},"aioseo_meta_data":{"post_id":"9813","title":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap | #site_title","description":"Swift 4.1 \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043b \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 (overload) \u0444\u0443\u043d\u043a\u0446\u0438\u0438 flatMap. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 flatMap \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445?","keywords":[{"label":"Swift 4.1","value":"Swift 4.1"},{"label":"flatMap","value":"flatMap"},{"label":"compactMap","value":"compactMap"},{"label":"partitionMap","value":"partitionMap"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 06:36:28","updated":"2026-02-22 20:13:47","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/bestkora.com\/IosDeveloper\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/\" title=\"Swift 4\">Swift 4<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/bestkora.com\/IosDeveloper"},{"label":"Swift 4","link":"https:\/\/bestkora.com\/IosDeveloper\/category\/swift-4\/"},{"label":"\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 flatMap \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 compactMap","link":"https:\/\/bestkora.com\/IosDeveloper\/a-tale-of-two-flat-maps\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/posts\/9813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/comments?post=9813"}],"version-history":[{"count":27,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/posts\/9813\/revisions"}],"predecessor-version":[{"id":10808,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/posts\/9813\/revisions\/10808"}],"wp:attachment":[{"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/media?parent=9813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/categories?post=9813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestkora.com\/IosDeveloper\/wp-json\/wp\/v2\/tags?post=9813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}