{"id":287107,"date":"2017-05-31T01:45:03","date_gmt":"2017-05-30T21:45:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=287107"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=287107","title":{"rendered":"\u0427\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0441 \u0436\u0434\u0435\u0442 \u0432 Swift 4?"},"content":{"rendered":"<p>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<p>  <\/p>\n<ol>\n<li><a href=\"#odnostoronnie-diapazony\">\u041e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b<\/a><\/li>\n<li><a href=\"#stroki\">\u0421\u0442\u0440\u043e\u043a\u0438<\/a><\/li>\n<li><a href=\"#privatnye-obyavleniya-vidimy-v-ekstenshenah-togo-zhe-fayla\">\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u044b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0430\u0445 \u0442\u043e\u0433\u043e \u0436\u0435 \u0444\u0430\u0439\u043b\u0430<\/a><\/li>\n<li><a href=\"#umnye-klyuchi-puti\">\u0423\u043c\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438<\/a><\/li>\n<li><a href=\"#arhivirovanie-i-serializaciya\">\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a><\/li>\n<li><a href=\"#uluchsheniya-v-dictionary-i-set\">\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 Dictionary \u0438 Set<\/a><\/li>\n<li><a href=\"#metod-mutablecollectionswapat\">\u041c\u0435\u0442\u043e\u0434 MutableCollection.swapAt<\/a><\/li>\n<li><a href=\"#reduce-s-podderzhkoy-inout\">reduce \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 inout<\/a><\/li>\n<li><a href=\"#generetiki-v-sabskriptah\">\u0413\u0435\u043d\u0435\u0440\u0435\u0442\u0438\u043a\u0438 \u0432 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445<\/a><\/li>\n<li><a href=\"#mostik-dlya-nsnumber\">\u041c\u043e\u0441\u0442\u0438\u043a \u0434\u043b\u044f NSNumber<\/a><\/li>\n<li><a href=\"#ekzemplyary-klassov-i-podtipov\">\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432<\/a><\/li>\n<\/ol>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"kak-eto-vse-zapustit-u-sebya\">\u041a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0443 \u0441\u0435\u0431\u044f?<\/h1>\n<p>  <\/p>\n<ol>\n<li><a href=\"https:\/\/swift.org\/download\/#snapshots\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u043d\u0435\u043f\u0448\u043e\u0442 Swift 4 \u0441 \u0441\u0430\u0439\u0442\u0430<\/a><\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0449\u0438\u043a<\/li>\n<li>\u041f\u0440\u043e\u0439\u0442\u0438 \u0432 <em>Xcode &gt; Toolchains &gt; Manage Toolchains<\/em> \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043d\u0435\u043f\u0448\u043e\u0442<\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/18b\/161\/204\/18b161204c8347209c880759cbf9fedd.png\"\/><\/p>\n<p>  <\/p>\n<h1 id=\"odnostoronnie-diapazony\">\u041e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0172-one-sided-ranges.md\">SE-0172<\/a> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 <code>RangeExpression<\/code> \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0438 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043d\u044b\u0445\/\u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u0438\u0431\u043e \u043d\u0438\u0436\u043d\u044f\u044f, \u043b\u0438\u0431\u043e \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430<\/p>\n<p>  <\/p>\n<h3 id=\"beskonechnye-posledovatelnosti\">\u0411\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044e\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 <code>enumerated()<\/code>, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0430\u0441\u044c \u0441 \u043d\u0443\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code>let letters = [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;] let numberedLetters = zip(1..., letters) Array(numberedLetters)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sabskripty-v-kollekciyah\">\u0421\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0442\u043e <code>startIndex<\/code> \u0438\u043b\u0438 <code>endIndex<\/code> \u201c\u0441\u0430\u043c\u043e\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u201d \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0438\u043b\u0438 \u043d\u0438\u0436\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code>let numbers = [1,2,3,4,5,6,7,8,9,10] numbers[5...] \/\/ \u0432\u043c\u0435\u0441\u0442\u043e numbers[5..&lt;numbers.endIndex]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sravnenie-patternov\">\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044f\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 <code>case<\/code> \u0438\u043b\u0438 <code>switch<\/code>. <em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e <code>switch<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u043b\u0438\u0448\u043d\u0438\u043c<\/em>.<\/p>\n<p>  <\/p>\n<pre><code>let value = 5 switch value { case 1...:     print(&quot;greater than zero&quot;) case 0:     print(&quot;zero&quot;) case ..&lt;0:     print(&quot;less than zero&quot;) default:     fatalError(&quot;unreachable&quot;) }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"stroki\">\u0421\u0442\u0440\u043e\u043a\u0438<\/h1>\n<p>  <\/p>\n<h3 id=\"mnogostrochnye-strokovye-literaly\">\u041c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0168-multi-line-string-literals.md\">SE-0168<\/a> \u0432\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432 (<code>&quot;&quot;&quot;<\/code>). \u0412 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u043a\u0430\u043a JSON \u0438 HTML \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u043d\u0438\u0445 \u0431\u0435\u0437\u043e \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0442\u0431\u0438\u0432\u043a\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  <\/p>\n<pre><code>let multilineString = &quot;&quot;&quot;     This is a multi-line string.     You don't have to escape &quot;quotes&quot; in here.     The position of the closing delimiter       controls whitespace stripping.     &quot;&quot;&quot; print(multilineString)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b <code>print<\/code> \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043d\u0430\u0436\u0430\u0432 (<em>View &gt; Debug Area &gt; Activate Console<\/em>).<\/p>\n<p>  <\/p>\n<h3 id=\"stroka-teper-opyat-kollekciya\">\u0421\u0442\u0440\u043e\u043a\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u044f\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0163-string-revision-1.md\">SE-0163<\/a> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f Swift 4. \u0421\u0430\u043c\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f (\u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0432 Swift 1.x), \u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c <code>String.CharacterView<\/code> \u0431\u044b\u043b\u0430 \u0441\u0432\u0435\u0440\u043d\u0443\u0442\u0430 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0438\u043f. (\u0414\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b, <code>UnicodeScalarView<\/code>, <code>UTF8View<\/code>, \u0438 <code>UTF16View<\/code>, \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442.)<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e SE-0163 \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d, \u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/em><\/p>\n<p>  <\/p>\n<pre><code>let greeting = &quot;Hello, !&quot; \/\/ \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0434\u043e .characters greeting.count for char in greeting {     print(char) }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"substring--novyy-tip-dlya-slaysov-strok\">Substring \u2014 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0441\u043b\u0430\u0439\u0441\u043e\u0432 \u0441\u0442\u0440\u043e\u043a<\/h3>\n<p>  <\/p>\n<p>\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0441\u043b\u0430\u0439\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u043e\u043c <code>Substring<\/code>. \u041e\u0431\u0430 \u0442\u0438\u043f\u0430 <code>String<\/code> \u0438 <code>Substring<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>StringProtocol<\/code>. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 API \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u0436\u0438\u0432\u0435\u0442 \u0432 <code>StringProtocol<\/code> \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>String<\/code> \u0438 <code>StringProtocol<\/code> \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e.<\/p>\n<p>  <\/p>\n<pre><code>let comma = greeting.index(of: &quot;,&quot;)! let substring = greeting[..&lt;comma] type(of: substring) \/\/ API \u043e\u0442 String \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 Substring print(substring.uppercased())<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"unicode-9\">Unicode 9<\/h3>\n<p>  <\/p>\n<p>Swift 4 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c Unicode 9, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0433\u0440\u0430\u0444\u0435\u043c \u0434\u043b\u044f \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u044d\u043c\u043e\u0434\u0437\u0438. \u0412\u0441\u0451 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043d\u0438\u0436\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code>&quot;&quot;.count \/\/ person + skin tone &quot;\u200d\u200d\u200d&quot;.count \/\/ family with four members &quot;\\u{200D}\\u{200D}\\u{200D}&quot;.count \/\/ family + skin tones &quot;\u200d&quot;.count \/\/ person + skin tone + profession<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0425\u0430\u0431\u0440\u0430\u043f\u0430\u0440\u0441\u0435\u0440 \u0441\u043e\u0436\u0440\u0430\u043b \u0432\u0441\u0435 \u044d\u043c\u043e\u0434\u0437\u0438, \u0441 \u043d\u0438\u043c\u0438 <a href=\"https:\/\/gist.github.com\/JiLiZART\/c0bfe8280fc0802ac634c68880e756a8\">\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442<\/a><\/em><\/p>\n<p>  <\/p>\n<h3 id=\"svoystvo-characterunicodescalars\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Character.unicodeScalars<\/code><\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u043e\u0447\u043a\u0430\u043c <code>Character<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0431\u0435\u0437 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 (<a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0178-character-unicode-view.md\">SE-0178<\/a>).<\/p>\n<p>  <\/p>\n<pre><code>let c: Character = &quot;&quot; Array(c.unicodeScalars)<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"privatnye-obyavleniya-vidimy-v-ekstenshenah-togo-zhe-fayla\">\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u044b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0430\u0445 \u0442\u043e\u0433\u043e \u0436\u0435 \u0444\u0430\u0439\u043b\u0430<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0169-improve-interaction-between-private-declarations-and-extensions.md\">SE-0169<\/a> \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u044b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0430\u0445 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u043e\u0432 \u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u00ab\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445\u00bb \u0432\u0435\u0449\u0435\u0439, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <code>fileprivate<\/code>.<\/p>\n<p>  <\/p>\n<pre><code>struct SortedArray&lt;Element: Comparable&gt; {     private var storage: [Element] = []     init(unsorted: [Element]) {         storage = unsorted.sorted()     } }  extension SortedArray {     mutating func insert(_ element: Element) {         \/\/ storage \u0442\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d         storage.append(element)         storage.sort()     } }  let array = SortedArray(unsorted: [3,1,2]) \/\/ storage _\u043d\u0435_ \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u0443\u0442 (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 fileprivate) \/\/array.storage \/\/ error: 'storage' is inaccessible due to 'private' protection level<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"umnye-klyuchi-puti\">\u0423\u043c\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438<\/h1>\n<p>  <\/p>\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043e\u0434\u043d\u0430 \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 Swift 4 \u044d\u0442\u043e \u043d\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043b\u044e\u0447\u0435\u0439 \u043f\u0443\u0442\u0438 <em>(key path) <\/em> \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432 <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0161-key-paths.md\">SE-0161<\/a>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043f\u0443\u0442\u0438 \u0432 Cocoa, \u0432 Swift \u043a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<pre><code>struct Person {     var name: String }  struct Book {     var title: String     var authors: [Person]     var primaryAuthor: Person {         return authors.first!     } }  let abelson = Person(name: &quot;Harold Abelson&quot;) let sussman = Person(name: &quot;Gerald Jay Sussman&quot;) let sicp = Book(title: &quot;Structure and Interpretation of Computer Programs&quot;, authors: [abelson, sussman])<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0438\u043c\u0435\u043d.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u043f\u0443\u0442\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u044d\u043a\u0441\u043b\u0435\u0448\u0430: <code>\\Book.title<\/code>. \u041b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f \u0432 Swift \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>[keyPath: \u2026]<\/code> \u2014 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043f\u0443\u0442\u0438. <\/p>\n<p>  <\/p>\n<pre><code>sicp[keyPath: \\Book.title] \/\/ \u041a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 sicp[keyPath: \\Book.primaryAuthor.name]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <code>KeyPath<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u044b \u043a \u043a\u043b\u044e\u0447\u0443 \u043f\u0443\u0442\u0438, \u0447\u0442\u043e\u0431 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  <\/p>\n<pre><code>let authorKeyPath = \\Book.primaryAuthor type(of: authorKeyPath) let nameKeyPath = authorKeyPath.appending(path: \\.name) \/\/ \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043c\u0435\u043d\u0438 \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c sicp[keyPath: nameKeyPath]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sabskripty-v-klyuchah-putey\">\u0421\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u043a\u043b\u044e\u0447\u0430\u0445 \u043f\u0443\u0442\u0435\u0439<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043a\u043b\u044e\u0447\u0430\u0445 \u043f\u0443\u0442\u0438 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u043e\u0442\u0430\u0446\u0438\u044e. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0445 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c, \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c \u0438\u043b\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u043d\u044d\u043f\u0448\u043e\u0442\u0435.<\/p>\n<p>  <\/p>\n<pre><code>\/\/sicp[keyPath: \\Book.authors[0].name] \/\/ INTERNAL ERROR: feature not implemented: non-property key path component<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"arhivirovanie-i-serializaciya\">\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0166-swift-archival-serialization.md\">SE-0166: Swift Archival &amp; Serialization<\/a> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u0442\u0438\u043f\u044b \u0432 Swift (\u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0438 \u0435\u043d\u0443\u043c\u044b) \u0431\u0443\u0434\u0443\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u044f. \u0422\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0435\u0431\u044f (\u0440\u0430\u0437-)\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Codable<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <code>Codable<\/code> \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u2014 \u0432\u0441\u0435 \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0430\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u0442\u0438\u043f\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 <code>Codable<\/code>. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e \u043a\u0430\u043a \u0442\u0438\u043f \u0441\u0435\u0431\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442. \u0412 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u044e\u0430\u043d\u0441\u043e\u0432 \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0442\u0430\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<pre><code>\/\/ \u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u0442\u0438\u043f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u043c (\u0438 \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u0447\u043b\u0435\u043d\u043e\u0432) \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b Codable struct Card: Codable {     enum Suit: String, Codable {         case clubs, spades, hearts, diamonds     }      enum Rank: Int, Codable {         case ace = 1, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king     }      var suit: Suit     var rank: Rank }  let hand = [Card(suit: .clubs, rank: .ace), Card(suit: .hearts, rank: .queen)]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"kodirovanie\">\u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0435 <code>Codable<\/code>, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043a\u043e\u0434\u0435\u0440\u044b \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0442 <code>Codable<\/code>, \u043d\u043e \u0432 Swift \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f JSON (<code>JSONEncoder<\/code> \u0438 <code>JSONDecoder<\/code>) \u0438 \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 (<code>PropertyListEncoder<\/code> \u0438 <code>PropertyListDecoder<\/code>). \u041e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0167-swift-encoders.md\">SE-0167<\/a>. <code>NSKeyedArchiver<\/code> \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 <code>Codable<\/code> \u0442\u0438\u043f\u044b<\/p>\n<p>  <\/p>\n<pre><code>import Foundation  var encoder = JSONEncoder()  \/\/ \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 JSONEncoder \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 encoder.dataEncodingStrategy encoder.dateEncodingStrategy encoder.nonConformingFloatEncodingStrategy encoder.outputFormatting encoder.userInfo  let jsonData = try encoder.encode(hand) String(data: jsonData, encoding: .utf8)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"dekodirovanie\">\u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<pre><code>let decoder = JSONDecoder() let decoded = try decoder.decode([Card].self, from: jsonData)<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"uluchsheniya-v-dictionary-i-set\">\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 <code>Dictionary<\/code> \u0438 <code>Set<\/code><\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0165-dict.md\">SE-0165<\/a> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439 \u0434\u043b\u044f <code>Dictionary<\/code> \u0438 <code>Set<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"inicializator-prinimayuschiy-posledovatelnost\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<pre><code>let names = [&quot;Cagney&quot;, &quot;Lacey&quot;, &quot;Bensen&quot;] let dict = Dictionary(uniqueKeysWithValues: zip(1..., names)) dict[2]<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"inicializator-sliyaniya-i-metod-sliyaniya\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0438 \u043c\u0435\u0442\u043e\u0434 \u0441\u043b\u0438\u044f\u043d\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e, \u043a\u0430\u043a \u0434\u0443\u0431\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<p>  <\/p>\n<pre><code>let duplicates = [(&quot;a&quot;, 1), (&quot;b&quot;, 2), (&quot;a&quot;, 3), (&quot;b&quot;, 4)] let letters = Dictionary(duplicates, uniquingKeysWith: { (first, _) in first }) letters  let defaults = [&quot;foo&quot;: false, &quot;bar&quot;: false, &quot;baz&quot;: false] var options = [&quot;foo&quot;: true, &quot;bar&quot;: false] \/\/ \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0443\u043f\u0430\u0434\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438: error: generic parameter 'S' could not be inferred \/\/ \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a https:\/\/bugs.swift.org\/browse\/SR-922 \/\/options.merge(defaults) { (old, _) in old }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sabskript-so-znacheniem-po-umolchaniyu\">\u0421\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0447\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439, \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0441\u0434\u0435\u043b\u0430\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043d\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<pre><code>dict[4, default: &quot;(unknown)&quot;] \/\/ \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u0432\u0440\u0430\u043f\u0438\u0442\u044c<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043c\u0443\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<p>  <\/p>\n<pre><code>let source = &quot;how now brown cow&quot; var frequencies: [Character: Int] = [:] for c in source {     frequencies[c, default: 0] += 1 } frequencies<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"specifichnye-dlya-slovarya-map-i-filter\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f <code>map<\/code> \u0438 <code>filter<\/code><\/h3>\n<p>  <\/p>\n<p><code>filter<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Dictionary<\/code> \u0430 \u043d\u0435 <code>Array<\/code>. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>mapValues<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/p>\n<p>  <\/p>\n<pre><code>let filtered = dict.filter {     $0.key % 2 == 0 } type(of: filtered)  let mapped = dict.mapValues { value in     value.uppercased() } mapped<\/code><\/pre>\n<p>  <\/p>\n<p><code>Set.filter<\/code> \u0442\u0430\u043a \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Set<\/code> \u0430 \u043d\u0435 <code>Array<\/code>.<\/p>\n<p>  <\/p>\n<pre><code>let set: Set = [1,2,3,4,5] let filteredSet = set.filter { $0 % 2 == 0 } type(of: filteredSet)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"gruppirovka-posledovatelnosti\">\u0413\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  <\/p>\n<p>\u0413\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0431\u0443\u043a\u0435\u0442\u044b. \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u043e \u0438\u0445 \u043f\u0435\u0440\u0432\u043e\u0439 \u0431\u0443\u043a\u0432\u0435.<\/p>\n<p>  <\/p>\n<pre><code>let contacts = [&quot;Julia&quot;, &quot;Susan&quot;, &quot;John&quot;, &quot;Alice&quot;, &quot;Alex&quot;] let grouped = Dictionary(grouping: contacts, by: { $0.first! }) grouped<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"metod-mutablecollectionswapat\">\u041c\u0435\u0442\u043e\u0434 <code>MutableCollection.swapAt<\/code><\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0173-swap-indices.md\">SE-0173<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e <code>swap(_:_:)<\/code>, \u043c\u0435\u0442\u043e\u0434 <code>swapAt(_:_:)<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043c\u0435\u043d\u044f\u0442\u044c, \u0430 \u043d\u0435 \u0441\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (\u0447\u0435\u0440\u0435\u0437 <code>inout<\/code> \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b).<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u043c\u0435\u043d \u0441 \u0434\u0432\u0443\u043c\u044f <code>inout<\/code> \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c<br \/>  \u0441 \u043d\u043e\u0432\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043f\u0430\u043c\u044f\u0442\u0438 <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0176-enforce-exclusive-access-to-memory.md\">SE-0176<\/a>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>swap(_:_:)<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<pre><code>var numbers = [1,2,3,4,5] numbers.swapAt(0,1)  \/\/ Will be illegal in Swift 4 (not implemented yet) swap(&amp;numbers[3], &amp;numbers[4]) numbers<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"reduce-s-podderzhkoy-inout\"><code>reduce<\/code> \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <code>inout<\/code><\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0171-reduce-with-inout.md\">SE-0171<\/a> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <code>reduce<\/code> \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>inout<\/code> \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>combine<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>reduce<\/code> \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0443\u0442\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>SE-0171 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d<\/p>\n<p>  <\/p>\n<pre><code>\/\/ \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 extension Sequence where Iterator.Element: Equatable {     func uniq() -&gt; [Iterator.Element] {         return reduce(into: []) { (result: inout [Iterator.Element], element) in             if result.last != element {                 result.append(element)             }         }     } }  [1,1,1,2,3,3,4].uniq()<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"generetiki-v-sabskriptah\">\u0413\u0435\u043d\u0435\u0440\u0435\u0442\u0438\u043a\u0438 \u0432 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445<\/h1>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0148-generic-subscripts.md\">SE-0148<\/a>, \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u044d\u0442\u043e \u0442\u0438\u043f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u043b\u044f\u0435\u0442 <code>JSON<\/code> \u0434\u0430\u043d\u043d\u044b\u0435: \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u0441 \u0433\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043c\u043e\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f.<\/p>\n<p>  <\/p>\n<pre><code>struct JSON {     fileprivate var storage: [String:Any]      init(dictionary: [String:Any]) {         self.storage = dictionary     }      subscript&lt;T&gt;(key: String) -&gt; T? {         return storage[key] as? T     } }  let json = JSON(dictionary: [     &quot;name&quot;: &quot;Berlin&quot;,     &quot;country&quot;: &quot;de&quot;,     &quot;population&quot;: 3_500_500     ])  \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c as? Int let population: Int? = json[&quot;population&quot;]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442 \u0432 <code>Collection<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code>extension Collection {     subscript&lt;Indices: Sequence&gt;(indices indices: Indices) -&gt; [Iterator.Element] where Indices.Iterator.Element == Index {         var result: [Element] = []         for index in indices {             result.append(self[index])         }         return result     } }  let words = &quot;Lorem ipsum dolor sit amet&quot;.split(separator: &quot; &quot;) words[indices: [1,2]]<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"mostik-dlya-nsnumber\">\u041c\u043e\u0441\u0442\u0438\u043a \u0434\u043b\u044f <code>NSNumber<\/code><\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0170-nsnumber_bridge.md\">SE-0170<\/a> \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441 \u043c\u043e\u0441\u0442\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0432 Swift \u0438 <code>NSNumber<\/code>.<\/p>\n<p>  <\/p>\n<pre><code>import Foundation  let n = NSNumber(value: UInt32(543)) let v = n as? Int8 \/\/ nil in Swift 4. This would be 31 in Swift 3 (try it!).<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"ekzemplyary-klassov-i-podtipov\">\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432<\/h1>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u043d\u0430 Objective-C <code>UIViewController &lt;SomeProtocol&gt; *<\/code> \u0432 Swift,<br \/>  \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0451 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e (<a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0156-subclass-existentials.md\">SE-0156<\/a>). \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>let variable: SomeClass &amp; SomeProtocol1 &amp; SomeProtocol2<\/code><\/p>\n<p>  <\/p>\n<pre><code>import Cocoa  protocol HeaderView {}  class ViewController: NSViewController {     let header: NSView &amp; HeaderView      init(header: NSView &amp; HeaderView) {         self.header = header         super.init(nibName: nil, bundle: nil)!     }      required init(coder decoder: NSCoder) {         fatalError(&quot;not implemented&quot;)     } }  \/\/ \u041d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e NSView \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \/\/ ViewController(header: NSView()) \/\/ error: argument type 'NSView' does not conform to expected type 'NSView &amp; HeaderView'  \/\/ \u0414\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0439\u0442\u0438 \u043a\u0430\u043a NSView (\u0441\u0430\u0431\u043a\u043b\u0430\u0441\u0441) \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b extension NSImageView: HeaderView {}  ViewController(header: NSImageView()) \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/code><\/pre>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/329580\/\"> https:\/\/habrahabr.ru\/post\/329580\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<p>  <\/p>\n<ol>\n<li><a href=\"#odnostoronnie-diapazony\">\u041e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b<\/a><\/li>\n<li><a href=\"#stroki\">\u0421\u0442\u0440\u043e\u043a\u0438<\/a><\/li>\n<li><a href=\"#privatnye-obyavleniya-vidimy-v-ekstenshenah-togo-zhe-fayla\">\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u044b \u0432 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u0430\u0445 \u0442\u043e\u0433\u043e \u0436\u0435 \u0444\u0430\u0439\u043b\u0430<\/a><\/li>\n<li><a href=\"#umnye-klyuchi-puti\">\u0423\u043c\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043f\u0443\u0442\u0438<\/a><\/li>\n<li><a href=\"#arhivirovanie-i-serializaciya\">\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a><\/li>\n<li><a href=\"#uluchsheniya-v-dictionary-i-set\">\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 Dictionary \u0438 Set<\/a><\/li>\n<li><a href=\"#metod-mutablecollectionswapat\">\u041c\u0435\u0442\u043e\u0434 MutableCollection.swapAt<\/a><\/li>\n<li><a href=\"#reduce-s-podderzhkoy-inout\">reduce \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 inout<\/a><\/li>\n<li><a href=\"#generetiki-v-sabskriptah\">\u0413\u0435\u043d\u0435\u0440\u0435\u0442\u0438\u043a\u0438 \u0432 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445<\/a><\/li>\n<li><a href=\"#mostik-dlya-nsnumber\">\u041c\u043e\u0441\u0442\u0438\u043a \u0434\u043b\u044f NSNumber<\/a><\/li>\n<li><a href=\"#ekzemplyary-klassov-i-podtipov\">\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432<\/a><\/li>\n<\/ol>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-287107","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=287107"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287107\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}