{"id":293436,"date":"2019-08-15T15:01:08","date_gmt":"2019-08-15T15:01:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293436"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293436","title":{"rendered":"\u0421\u0438\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432 Swift. \u0427\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0434\u0440\u0443\u0437\u044c\u044f. \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/g6Xn\/\">\u00abiOS \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u041f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u043a\u0443\u0440\u0441\u00bb<\/a> \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u00ab\u0421\u0438\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432 Swift\u00bb.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/no\/j4\/0y\/noj40ysuc5kmkbuyrigfdtytcmw.png\"><\/p>\n<hr>\n<p>  <i>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0443\u0441\u043b\u043e\u0432\u0438\u044f where, \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u043f\u0440\u043e\u0447\u0435\u0435\u2026<\/i><\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/462753\/\">\u00ab\u0421\u0438\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432 Swift. \u0427\u0430\u0441\u0442\u044c 1\u00bb<\/a> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c generic-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, generic-\u0442\u0438\u043f\u044b \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a, \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u0432\u0430\u043c \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p>  \u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u0430\u0434\u0430\u0435\u0442 \u0438\u043c\u044f-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u0434\u043b\u044f \u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0438\u043f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d. \u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>associatedtype<\/code>.<a name=\"habracut\"><\/a><\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/462753\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>.<\/p>\n<pre><code class=\"swift\">protocol Stackable {     associatedtype Element     mutating func push(element: Element)     mutating func pop() -&gt; Element?     func peek() throws -&gt; Element     func isEmpty() -&gt; Bool     func count() -&gt; Int     subscript(i: Int) -&gt; Element { get } }<\/code><\/pre>\n<p>   \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Stackable<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u0435\u043a.<\/p>\n<p>  \u041b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>Stackable<\/code>, \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u0442\u0435\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u044f\u0441\u043d\u043e, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0435\u0433\u043e \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 \u0441\u0442\u0435\u043a \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c:<\/p>\n<pre><code class=\"swift\">enum StackError: Error {     case Empty(message: String) }  protocol Stackable {     associatedtype Element     mutating func push(element: Element)     mutating func pop() -&gt; Element?     func peek() throws -&gt; Element     func isEmpty() -&gt; Bool     func count() -&gt; Int     subscript(i: Int) -&gt; Element { get } }  public struct Stack&lt;T&gt;: Stackable {     public typealias Element = T          var array: [T] = []          init(capacity: Int) {         array.reserveCapacity(capacity)     }          public mutating func push(element: T) {         array.append(element)     }          public mutating func pop() -&gt; T? {         return array.popLast()     }          public func peek() throws -&gt; T {         guard !isEmpty(), let lastElement = array.last else {             throw StackError.Empty(message: \"Array is empty\")         }         return lastElement     }          func isEmpty() -&gt; Bool {        return array.isEmpty     }          func count() -&gt; Int {         return array.count     } }  extension Stack: Collection {     public func makeIterator() -&gt; AnyIterator&lt;T&gt; {         var curr = self         return AnyIterator { curr.pop() }     }          public subscript(i: Int) -&gt; T {         return array[i]     }          public var startIndex: Int {         return array.startIndex     }          public var endIndex: Int {         return array.endIndex     }          public func index(after i: Int) -&gt; Int {         return array.index(after: i)     } }  extension Stack: CustomStringConvertible {     public var description: String {         let header = \"***Stack Operations start*** \"         let footer = \" ***Stack Operation end***\"         let elements = array.map{ \"\\($0)\" }.joined(separator: \"\\n\")         return header + elements + footer     } }  var stack = Stack&lt;Int&gt;(capacity: 10) stack.push(element: 1) stack.pop()  stack.push(element: 3) stack.push(element: 4) print(stack)<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/h3>\n<p>   \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443.<\/p>\n<pre><code class=\"swift\">protocol Container {     associatedtype Item     mutating func append(_ item: Item)     var count: Int { get }     subscript(i: Int) -&gt; Item { get } } extension Array: Container {}<\/code><\/pre>\n<p>   <\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f:<\/h3>\n<p>   \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 \u0434\u043b\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u044d\u0442\u0438\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c.<br \/>   \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Stackable<\/code>.<\/p>\n<pre><code class=\"swift\">protocol Stackable {     associatedtype Element: Equatable     mutating func push(element: Element)     mutating func pop() -&gt; Element?     func peek() throws -&gt; Element     func isEmpty() -&gt; Bool     func count() -&gt; Int     subscript(i: Int) -&gt; Element { get } }<\/code><\/pre>\n<p>   \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0435\u043a\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c <code>Equatable<\/code>, \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<h3>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430:<\/h3>\n<p>   \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043c\u043e\u0436\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<pre><code class=\"swift\">protocol SuffixableContainer: Container {     associatedtype Suffix: SuffixableContainer where Suffix.Item == Item     func suffix(_ size: Int) -&gt; Suffix }<\/code><\/pre>\n<p>  <code>Suffix<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>SuffixableContainer<\/code> (\u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b), \u0430 \u0435\u0433\u043e \u0442\u0438\u043f <code>Item<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0442\u0438\u043f\u043e\u043c <code>Item<\/code> \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Swift \u0432 <code>Protocol Sequence<\/code> \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430: <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0157-recursive-protocol-constraints.md\">https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0157-recursive-protocol-constraints.md<\/a><\/p>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f Generic-\u0442\u0438\u043f\u0430:<\/h3>\n<p>   <\/p>\n<blockquote><p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442\u0435 generic-\u0442\u0438\u043f, \u0432\u044b \u043d\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0442\u0435\u043b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0438\u043f\u0430 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p><\/blockquote>\n<pre><code class=\"swift\">extension Stack {    var topItem: Element? {      return items.isEmpty ? nil : items[items.count - 1]    } }<\/code><\/pre>\n<p>   <\/p>\n<h3>Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 where<\/h3>\n<p>  \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c where<\/i>. Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 \u0438\u043b\u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0438\u043f\u0430 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0431\u044b\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438. Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>where<\/code>, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438. Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u0438\u0433\u0443\u0440\u043d\u043e\u0439 \u0441\u043a\u043e\u0431\u043a\u043e\u0439 \u0442\u0435\u043b\u0430 \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"swift\">func allItemsMatch&lt;C1: Container, C2: Container&gt;     (_ someContainer: C1, _ anotherContainer: C2) -&gt; Bool     where C1.Item == C2.Item, C1.Item: Equatable { }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0441 Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 where<\/h3>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Stack<\/code> \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>isTop (_ :)<\/code>.<\/p>\n<pre><code class=\"swift\">extension Stack where Element: Equatable {     func isTop(_ item: Element) -&gt; Bool {         guard let topItem = items.last else {             return false         }         return topItem == item     } }<\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>isTop (_ :)<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u0442\u0435\u043a\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 Equatable. \u0422\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u041a \u0443\u0441\u043b\u043e\u0432\u0438\u044e <code>where<\/code> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0432 \u0438\u0445 \u0437\u0430\u043f\u044f\u0442\u043e\u0439.<\/p>\n<h3>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0441 Generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c where:<\/h3>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u0432 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f.<\/p>\n<pre><code class=\"swift\">protocol Container {     associatedtype Item     mutating func append(_ item: Item)     var count: Int { get }     subscript(i: Int) -&gt; Item { get } associatedtype Iterator: IteratorProtocol where Iterator.Element == Item     func makeIterator() -&gt; Iterator } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443, \u0432\u043a\u043b\u044e\u0447\u0430\u044f generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>ComparableContainer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b <code>Item<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b <code>Comparable<\/code>:<\/p>\n<pre><code class=\"swift\">protocol ComparableContainer: Container where Item: Comparable { } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0430\u043b\u0438\u0430\u0441\u044b \u0442\u0438\u043f\u043e\u0432:<\/h3>\n<p>  \u0410\u043b\u0438\u0430\u0441 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041e\u043d \u0432\u0441\u0435 \u0435\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u043c (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f).<\/p>\n<pre><code class=\"swift\">typealias StringDictionary&lt;Value&gt; = Dictionary&lt;String, Value&gt; var d1 = StringDictionary&lt;Int&gt;() var d2: Dictionary&lt;String, Int&gt; = d1 \/\/ okay: d1 and d2 have the same type, Dictionary&lt;String, Int&gt; typealias DictionaryOfStrings&lt;T : Hashable&gt; = Dictionary&lt;T, String&gt; typealias IntFunction&lt;T&gt; = (T) -&gt; Int typealias Vec3&lt;T&gt; = (T, T, T) typealias BackwardTriple&lt;T1,T2,T3&gt; = (T3, T2, T1)<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0442\u0438\u043f\u0430.<br \/>  \u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"swift\">typealias ComparableArray&lt;T where T : Comparable&gt; = Array&lt;T&gt; <\/code><\/pre>\n<p>  <\/p>\n<h3>Generic-\u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b<\/h3>\n<p>  \u0421\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code>. \u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0438\u043c\u044f \u0442\u0438\u043f\u0430 \u0432 \u0443\u0433\u043b\u043e\u0432\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043f\u043e\u0441\u043b\u0435 <code>subscript<\/code>, \u0438 \u043f\u0438\u0448\u0435\u0442\u0435 generic-\u0443\u0441\u043b\u043e\u0432\u0438\u0435 <code>where<\/code> \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u0438\u0433\u0443\u0440\u043d\u043e\u0439 \u0441\u043a\u043e\u0431\u043a\u043e\u0439 \u0442\u0435\u043b\u0430 \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<pre><code class=\"swift\">extension Container {     subscript&lt;Indices: Sequence&gt;(indices: Indices) -&gt; [Item]         where Indices.Iterator.Element == Int {             var result = [Item]()             for index in indices {                 result.append(self[index])             }             return result     } }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432<\/h3>\n<p>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a Stack <code>&lt;<\/code>T<code>&gt;<\/code>, \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u043a Int. \u042d\u0442\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0442\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Int, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043c\u0435\u043d\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/b>.<\/p>\n<p>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f generic-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u0438\u043d\u043b\u0430\u0439\u043d \u0432\u044b\u0437\u043e\u0432\u044b, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/h3>\n<p>  Generic-\u0442\u0438\u043f\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b.<\/p>\n<pre><code class=\"swift\">func ==&lt;T: Equatable&gt;(lhs: Matrix&lt;T&gt;, rhs: Matrix&lt;T&gt;) -&gt; Bool {     return lhs.array == rhs.array  }<\/code><\/pre>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0449\u044c \u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u0445<\/h3>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <i>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435<\/i> \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430?<\/p>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 (T).<\/p>\n<h2>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f:<\/h2>\n<p>  <a href=\"https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/Generics.rst\">https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/Generics.rst<\/a><br \/>  <a href=\"https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/GenericsManifesto.md\">https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/GenericsManifesto.md<\/a><br \/>  <a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2018\/406\/\">https:\/\/developer.apple.com\/videos\/play\/wwdc2018\/406\/<\/a><br \/>  <a href=\"https:\/\/www.youtube.com\/watch?v=ctS8FzqcRug\">https:\/\/www.youtube.com\/watch?v=ctS8FzqcRug<\/a><br \/>  <a href=\"https:\/\/medium.com\/@vhart\/protocols-generics-and-existential-containers-wait-what-e2e698262ab1\">https:\/\/medium.com\/@vhart\/protocols-generics-and-existential-containers-wait-what-e2e698262ab1<br \/>  <\/a><\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/otus.pw\/g6Xn\/\">\u043a\u0443\u0440\u0441\u0435<\/a>.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/463789\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/463789\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0434\u0440\u0443\u0437\u044c\u044f. \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/g6Xn\/\">\u00abiOS \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u041f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u043a\u0443\u0440\u0441\u00bb<\/a> \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u00ab\u0421\u0438\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432 Swift\u00bb.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/no\/j4\/0y\/noj40ysuc5kmkbuyrigfdtytcmw.png\"><\/p>\n<hr>\n<p>  <i>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0443\u0441\u043b\u043e\u0432\u0438\u044f where, \u0441\u0430\u0431\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u043f\u0440\u043e\u0447\u0435\u0435\u2026<\/i><\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/462753\/\">\u00ab\u0421\u0438\u043b\u0430 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432 Swift. \u0427\u0430\u0441\u0442\u044c 1\u00bb<\/a> \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c generic-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, generic-\u0442\u0438\u043f\u044b \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a, \u044f \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0430 \u0432\u0430\u043c \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p>  \u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0437\u0430\u0434\u0430\u0435\u0442 \u0438\u043c\u044f-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443 \u0434\u043b\u044f \u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0438\u043f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d. \u0421\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>associatedtype<\/code>.<\/p>\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-293436","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293436","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=293436"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293436\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}