{"id":6186,"date":"2020-08-24T17:38:54","date_gmt":"2020-08-24T12:08:54","guid":{"rendered":"https:\/\/www.innovationm.com\/blog\/?p=6186"},"modified":"2020-08-24T17:41:23","modified_gmt":"2020-08-24T12:11:23","slug":"swift-generics","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/swift-generics\/","title":{"rendered":"Swift Generics"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Generics are simple yet one of the most powerful features of Swift programming language. Generic code enables us to write flexible and reusable functions that can work with any data type. Most of the Swift standard library is written using generics code. We have been using generic in our projects for a long time without even realizing it, for example, Swift&#8217;s collection types I.e. Array and Dictionary are both generic collections as we can create array or dictionary using any specified type including integer, float, double, etc.<\/span><\/p>\n<p><b>Problem without Generics<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We must understand the problem that we generally face if we don&#8217;t use generics in our code. In the following code, a function add Numbers() is supposed to add two numbers that are being passed into it.\u00a0<\/span><\/p>\n<pre class=\"lang:default decode:true \">func addNumbers(_ a:Int, _ b:Int) -&gt; Int{\r\n\r\n\u00a0\u00a0\u00a0\u00a0let sum = a + b\r\n\r\n\u00a0\u00a0\u00a0\u00a0return sum\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">The function accepts two Integer parameters and returns the sum by adding these two numbers. We can call this method to add two integer numbers. This function is useful but what if, we also need to add the floating-point numbers or double parameters. In that case, we need to create two specific functions again which would accept double and float parameters, As given below.<\/span><\/p>\n<pre class=\"lang:default decode:true \">func addNumbers(_ a:Float, _ b:Float) -&gt; Float{\r\n\r\n\u00a0\u00a0\u00a0\u00a0let sum = a + b\r\n\r\n\u00a0\u00a0\u00a0\u00a0return sum\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">If you notice, the body of two functions is similar, the only difference is the parameters that the functions accept.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In Other Words, we may need to create n number of functions to add n data type of variables. However, this approach is not useful enough since it conflicts the concepts of code reusability and readability in swift.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, if we could have written a single function that can accept any type of parameters, that would be more flexible and useful.<\/span><\/p>\n<p><b>Generic Functions<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Generic functions are the ones that can work with any type. The generic version of the addNumbers() method is given below.<\/span><\/p>\n<pre class=\"lang:default decode:true \">func addNumbers&lt;T:Numeric&gt;(_ a : T, b : T) -&gt; T{\r\n\r\n\u00a0\u00a0\u00a0\u00a0let sum = a + b\r\n\r\n\u00a0\u00a0\u00a0\u00a0return sum\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">The body of the generic and non-generic method addNumbers() is similar. However, the two are declared differently. The generic method uses a placeholder (T) instead of an actual data type. The placeholder says that T must be a numeric type (Int, Double, or Float) in this particular case of adding two numeric values. The actual type to use instead of T is determined each time the function gets called. Here, we can pass any numeric type value to this function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Consider the following example.<\/span><\/p>\n<pre class=\"lang:default decode:true\">class MyCalculation{\r\n\r\nfunc addNumbers&lt;T:Numeric&gt;(_ a : T, b : T) -&gt; T{\r\n\r\n\u00a0\u00a0\u00a0\u00a0let sum = a + b\r\n\r\n\u00a0\u00a0\u00a0\u00a0return sum\r\n\r\n}\r\n\r\n}\r\n\r\nvar c = MyCalculation()\r\n\r\nprint(c.addNumbers(10.4, b: 4)) \/\/ it prints 14.4<\/pre>\n<p><b>Generic Types<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Swift also facilitates us to declare the generic types in addition to Generic functions. The Generic Types are the user-defined classes, structures, and enumerations that can work with any data type similar to array or dictionary.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here, we will write a generic type Stack that will be an ordered set of values that allows a new item to be inserted only to the end of the collection. Generally, items in the stack can be only be inserted and deleted at one end called top of the stack. The operations are called push and pop.<\/span><\/p>\n<p><b>Non-Generic Stack<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The Non-Generic version of the stack is defined below. The struct IntStack can only work with the Integer values. However, the structure uses the array property called elements to store the values. It provides two operations push () and pop () which can push and pop the elements in the stack. The IntStack doesn&#8217;t work with any type of values as it is non-generic and can only be useful to the integers. <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<pre class=\"lang:default decode:true \">struct IntStack{\r\n\r\n\u00a0\u00a0\u00a0\u00a0var elements = Array&lt;Int&gt;()\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func push(_ elem : Int){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0elements.append(elem)\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\u00a0 \u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func pop() -&gt; Int{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements.removeLast()\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n}\r\n<\/pre>\n<p><b style=\"font-size: 1rem;\">Generic Stack<\/b><\/p>\n<p><span style=\"font-weight: 400;\">If we notice, the non-generic and generic version of the stack is somehow similar. However, the structure Stack can work with any type of values with the type parameter called Element mentioned in the declaration. It defines a placeholder name for a data type which is to be defined later.\u00a0<\/span><\/p>\n<pre class=\"lang:default decode:true \">struct Stack&lt;Element&gt;{\r\n\r\n\u00a0\u00a0\u00a0\u00a0var elements = Array&lt;Element&gt;()\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func push(_ elem : Element){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0elements.append(elem)\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func pop() -&gt; Element{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements.removeLast()\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">Since we have defined structure stack to be the generic type, now we can use Stack in our code to be the collection of any valid type in the swift, like array and dictionary. Consider the following example which uses Stack to define the stack of integers and strings.<\/span><\/p>\n<pre class=\"lang:default decode:true \">var stackOfInt = Stack&lt;Int&gt;()\r\n\r\nstackOfInt.push(10)\r\n\r\nstackOfInt.push(20)\r\n\r\nprint(stackOfInt)\r\n\r\nstackOfInt.pop()\r\n\r\nprint(stackOfInt)\r\n\r\n\r\nvar stackOfStrings = Stack&lt;String&gt;()\r\n\r\nstackOfStrings.push(\"abc\")\r\n\r\nstackOfStrings.push(\"name\")\r\n\r\nprint(stackOfStrings)\r\n\r\nstackOfStrings.pop()\r\n\r\nprint(stackOfStrings)<\/pre>\n<p><b>Extending a Generic Type<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We can create an extension for the Generic types, however, we need not mention the type parameter list while extending a Generic type as it is already defined in the original type definition and is available in the body of the extension. Original type parameter names are used to refer to the type parameters from the original definition.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the following example, we have added a read-only computed property <\/span><b>topItem <\/b><span style=\"font-weight: 400;\">to the Stack type, which returns nil if the stack is empty otherwise it returns the topmost element of the stack.<\/span><\/p>\n<pre class=\"lang:default decode:true \">extension Stack{\r\n\r\n\u00a0\u00a0\u00a0\u00a0var topElement:Element?{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if elements.isEmpty{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return nil\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}else{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements[elements.count - 1]\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n}<\/pre>\n<p><b>Associated Types<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Associated types are defined as the part of the protocol to provide a placeholder name to a type that is used in the protocol. The actual type used for that associated type is defined when any class conforms to the protocol. It is specified with the <\/span><b>associatetype <\/b><span style=\"font-weight: 400;\">keyword.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">An associated type Element is defined as the part of the protocol Collection given below. The class which adopts this protocol is provided functionality to append a new element into the collection of type Element.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The count is the get only property which specifies the count of the collection. The subscript takes an integer index value so that we can retrieve every value in the collection.\u00a0<\/span><\/p>\n<pre class=\"lang:default decode:true \">protocol Collection {\r\n\r\n\u00a0\u00a0\u00a0\u00a0associatedtype Element\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func append(_ element : Element)\r\n\r\n\u00a0\u00a0\u00a0\u00a0var count:Int{ get }\r\n\r\n\u00a0\u00a0\u00a0\u00a0subscript(index:Int) -&gt; Element { get }\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">Here, the protocol collection must ensure the right type is being passed into the append () method, and also the subscript returns the same type which gets appended into the collection. For this purpose, the protocol defines an associated type Element which is passed into the append method also returns as a collection element. The conforming class defines the actual type for the associated type defined in the protocol.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the following example, our generic type Stack conforms to the Collection protocol and uses the associated type to put the values into it.<\/span><\/p>\n<pre class=\"lang:default decode:true \">struct Stack&lt;Element&gt; : Collection{\r\n\r\n\u00a0\u00a0\u00a0\u00a0var elements = Array&lt;Element&gt;()\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func push(_ elem : Element){\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0elements.append(elem)\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func pop() -&gt; Element{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements.removeLast()\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0typealias Element = Element\u00a0\u00a0\u00a0\u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0mutating func append(_ element: Element) {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self.push(element)\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0var count : Int{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements.count\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\r\n\r\n\u00a0\u00a0\u00a0\u00a0subscript(index: Int) -&gt; Element {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return elements[index]\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">Also, we can restrict the type parameters associated with the Generic function, type, or subscript. We can define certain requirements on the type parameters associated with the Generic types. However, we have used the type constraints in the very first example of the generic function in this tutorial, where we have restricted the Type Parameter T to be Numeric.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, Generics are simple yet one of the most powerful features of the swift programming language which can enhance the code reusability and readability in our iOS projects.\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generics are simple yet one of the most powerful features of Swift programming language. Generic code enables us to write flexible and reusable functions that can work with any data type. Most of the Swift standard library is written using generics code. We have been using generic in our projects for a long time without [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,71],"tags":[],"class_list":["post-6186","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobile"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift Generics - InnovationM - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/swift-generics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift Generics - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"Generics are simple yet one of the most powerful features of Swift programming language. Generic code enables us to write flexible and reusable functions that can work with any data type. Most of the Swift standard library is written using generics code. We have been using generic in our projects for a long time without [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/swift-generics\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-24T12:08:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-24T12:11:23+00:00\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Swift Generics\",\"datePublished\":\"2020-08-24T12:08:54+00:00\",\"dateModified\":\"2020-08-24T12:11:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/\"},\"wordCount\":1044,\"commentCount\":0,\"articleSection\":[\"iOS\",\"Mobile\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/\",\"name\":\"Swift Generics - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"datePublished\":\"2020-08-24T12:08:54+00:00\",\"dateModified\":\"2020-08-24T12:11:23+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/swift-generics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swift Generics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift Generics - InnovationM - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/swift-generics\/","og_locale":"en_US","og_type":"article","og_title":"Swift Generics - InnovationM - Blog","og_description":"Generics are simple yet one of the most powerful features of Swift programming language. Generic code enables us to write flexible and reusable functions that can work with any data type. Most of the Swift standard library is written using generics code. We have been using generic in our projects for a long time without [&hellip;]","og_url":"https:\/\/www.innovationm.com\/blog\/swift-generics\/","og_site_name":"InnovationM - Blog","article_published_time":"2020-08-24T12:08:54+00:00","article_modified_time":"2020-08-24T12:11:23+00:00","author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Swift Generics","datePublished":"2020-08-24T12:08:54+00:00","dateModified":"2020-08-24T12:11:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/"},"wordCount":1044,"commentCount":0,"articleSection":["iOS","Mobile"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/swift-generics\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/","url":"https:\/\/www.innovationm.com\/blog\/swift-generics\/","name":"Swift Generics - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"datePublished":"2020-08-24T12:08:54+00:00","dateModified":"2020-08-24T12:11:23+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/swift-generics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/swift-generics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Swift Generics"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/6186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=6186"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/6186\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=6186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=6186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=6186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}