

{"id":120677,"date":"2023-11-21T18:00:39","date_gmt":"2023-11-21T12:30:39","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=120677"},"modified":"2023-11-21T18:24:37","modified_gmt":"2023-11-21T12:54:37","slug":"swift-functions","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/swift-functions\/","title":{"rendered":"Swift Functions with Examples"},"content":{"rendered":"<p>Functions are reusable blocks of code in a program. It performs a specific task like addition or printing or even some other complex task. It might take parameters, and it might also return values. It makes our code more modular. In this article, we\u2019ll learn about the basics of functions, functions with or without parameters and return values, their different types and their usage in programming in Swift.<\/p>\n<h2>Kinds of Functions in Swift<\/h2>\n<p>There are two main kinds of functions. They can be standard library functions, or they can be user-defined functions.<\/p>\n<h3>Library Functions<\/h3>\n<p>Swift offers inbuilt functions for our use. These are known as standard library functions.<\/p>\n<p>Some of the common library functions are print(), pow(), etc.<\/p>\n<p>These can directly be used in our programs. These library functions are included in frameworks, so we need to import the framework corresponding to it.<\/p>\n<p>For example, pow() is defined in the Foundation Framework of Swift.<\/p>\n<h3>User-defined Functions<\/h3>\n<p>Users define their own functions. These are known as user-defined functions. <strong>These kinds of functions are discussed in detail below<\/strong>.<\/p>\n<h3>Function Declaration in Swift<\/h3>\n<p>We use the func keyword followed by the name of the function to define a function. We mention the parameters of the function within parentheses (). We can optionally specify the return type after parentheses. The body of the function is written within braces {}. We write the return statement at the end of the body of the function.<\/p>\n<p><strong>The syntax of a function.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func functionName(parameter1, parameter2, ..., parameterN) -&gt; returnType{\r\n    \/\/Function Body\r\n    Return statement\r\n}<\/pre>\n<p><strong>For example, we have to define a function that multiplies 2 numbers.<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Parts of the function<\/b><\/td>\n<td><b>Name of the component in the function<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Name of the function<\/span><\/td>\n<td><span style=\"font-weight: 400\">multiply<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Parameters<\/span><\/td>\n<td><span style=\"font-weight: 400\">num1, num2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Return Type<\/span><\/td>\n<td><span style=\"font-weight: 400\">Int<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func multiply(num1: Int, num2: Int) -&gt; Int{\r\n    let temp = num1 * num2\r\n    return temp\r\n}<\/pre>\n<h3>Calling a function<\/h3>\n<p>We call a function by writing the function name followed by writing the parameters (if they are defined).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func multiply(num1: Int, num2: Int) -&gt; Int{\r\n    let temp = num1 * num2\r\n    return temp\r\n}\r\n\r\nvar product = multiply(num1: 4, num2: 5)\r\nprint(\"Product: \\(product)\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong>Product:<\/strong> 20<\/p>\n<h3>Function, Parameters and Return Values<\/h3>\n<p>A function might take a parameter. It might have a return value. It can also have an optional return value. It can also have an implicit return value. Based on a specific scenario and use case, we might have a parameter or return value. Below, we have discussed each of these with examples.<\/p>\n<h4>Function with Parameters<\/h4>\n<p>Functions with parameters are functions that contain one or more parameters in their argument.<\/p>\n<p><strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greetName(name:String){\r\n    print(\"Hello from \\(name)!\")\r\n}\r\n\r\ngreetName(name: \"DataFlair\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<h4>Function without Parameters<\/h4>\n<p>Functions can also be defined without parameters. <strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(){\r\n    print(\"Hello from DataFlair!\")\r\n}\r\n\r\ngreet()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<h4>Function with Return Values<\/h4>\n<p>Functions with return values usually return one or more values after completion of the task. We need to specify the return type of the function. We write an arrow symbol -&gt; after the parentheses followed by the return type. We can refer to the following syntax to understand it better.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func functionName() -&gt; ReturnType{\r\n    \/\/body\r\n    Return value\r\n}<\/pre>\n<p><strong>Example for the same.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func addNums(num1: Int, num2: Int) -&gt; Int{\r\n    return num1 + num2\r\n}\r\n\r\nlet sum = addNums(num1: 20, num2: 23)\r\nprint(\"Sum is \\(sum)\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Sum is 43<\/p>\n<h4>Function without Return Values<\/h4>\n<p>A function can also be written without return values. These functions return a special type known as void type. <strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(){\r\n    print(\"Hello from DataFlair!\")\r\n}\r\n\r\ngreet()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<h4>Function with Optional Return Values<\/h4>\n<p>When we are not sure whether we will get a result or not, we can use optional return values. We can define these by adding a question mark \u2018?\u2019 after the return type of the function. If there is no value to return, nil is returned.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func findDataFlair(sentence: String) -&gt; String?{\r\n    if sentence.contains(\"DataFlair\"){\r\n        return \"DataFlair\"\r\n    }else{\r\n        return nil\r\n    }\r\n}\r\nlet exampleSentence = \"Hello from DataFlair\"\r\n\r\nif let example = findDataFlair(sentence: exampleSentence){\r\n    print(\"\\(example) found.\")\r\n}else{\r\n    print(\"Not found.\")\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>DataFlair found.<\/p>\n<h4>Function with Implicit Return Values<\/h4>\n<p>In some functions, we don\u2019t need to explicitly write the return statement in the function declaration. The whole body of the function can be returned in a single expression. <strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet() -&gt; String{\r\n    \"Hello from DataFlair!\"\r\n}\r\n\r\nlet example: String = greet()\r\nprint(example)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<h3>More on Swift Function Parameters<\/h3>\n<p>Swift offers several uses of parameters. They can be used in several ways. We can use this based on our use case and convenience. Some of these are argument labels, local and external parameter names, variadic parameters and InOut parameters.<\/p>\n<h4>Local Parameter Names and External Parameter Names<\/h4>\n<p>We use local parameter names inside the function body locally. It is also known as internal parameter names.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(name: String){\r\n    \/\/name is an internal parameter\r\n    print(\"Hello from \\(name)!\")\r\n}<\/pre>\n<p>We use external parameter names while calling the function externally. It is also known as argument labels.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(name: String){\r\n    \/\/name is an internal parameter\r\n    print(\"Hello from \\(name)!\")\r\n}\r\n\r\n\/\/name is an external parameter here\r\ngreet(name: \"DataFlair\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<p>Argument Labels are explained in detail in the next subtopic.<\/p>\n<h4>Argument Labels<\/h4>\n<p>Argument Labels are descriptive names of function parameters. We write them in the function signature when we call them externally.<\/p>\n<p><strong>An example of argument labels is as follows<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(fromPerson name: String){\r\n    print(\"Hello from \\(name)!\")\r\n}\r\n\r\ngreet(fromPerson: \"DataFlair\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<p>We can also omit these argument labels while calling the function. We can do it by writing an underscore \u2018_\u2019 instead of a label while defining the function. <strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(_ name: String){\r\n    print(\"Hello from \\(name)!\")\r\n}\r\n\r\ngreet(\"DataFlair\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair!<\/p>\n<h4>Variadic Parameters<\/h4>\n<p>We can define a function with multiple parameters with the help of variadic parameters. We do it by adding an ellipsis (&#8230;) after the parameter name. <strong>For example,<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func sum(numbers: Int...)-&gt;Int{\r\n    var total = 0\r\n    for number in numbers{\r\n        total += number\r\n    }\r\n    return total\r\n}\r\n\r\nprint(sum(numbers: 2, 5, 7, 9, 10))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>33<\/p>\n<h4>InOut Parameters<\/h4>\n<p>Inout parameters change the value of the variable passed through a function. To declare an inout parameter, we write the inout keyword before the data type. The variable needs to be mutable.<\/p>\n<p>We call a function with inout parameters by prefixing the variables with an ampersand \u2018&amp;\u2019. This means that we want to pass them by reference. This allows the function to modify its value.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func swapValues(_ num1: inout Int, _ num2: inout Int){\r\n    let temp = num1\r\n    num1 = num2\r\n    num2 = temp\r\n}\r\n\r\nvar num1 = 6\r\nvar num2 = 10\r\n\r\nprint(\"Before Swapping \\(num1), \\(num2)\")\r\nswapValues(&amp;num1, &amp;num2)\r\nprint(\"After Swapping \\(num1), \\(num2)\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Before Swapping 6, 10<br \/>\nAfter Swapping 10, 6<\/p>\n<h3>Function Types<\/h3>\n<p>We can convert functions into data types. We can treat them as regular data types. We can assign them to variables. We can pass them as arguments in other functions. We can also return them from other functions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func greet(name: String){\r\n    print(\"Hello from \\(name)\")\r\n}\r\nlet printGreetings: (String) -&gt; Void = greet\r\n\r\nprintGreetings(\"DataFlair\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Hello from DataFlair<\/p>\n<h3>Nested Functions<\/h3>\n<p>Functions defined inside another function are known as nested functions. <strong>The syntax of nested functions is as follows.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func functionName1(){\r\n    \/\/func body\r\n    func functionName2(){\r\n        \/\/func body\r\n    }\r\n}<\/pre>\n<p><strong>The example below defines the inner and outer functions.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">func function1(){\r\n    print(\"Outer Function\")\r\n    func function2(){\r\n        print(\"Inner Function\")\r\n    }\r\n    \r\n    function2()\r\n}\r\nfunction1()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Outer Function<br \/>\nInner Function<\/p>\n<p>We cannot call the inner function outside of the outer function. It throws errors if we can an inner function from outside of the outer function.<\/p>\n<h3>Conclusion<\/h3>\n<p>Functions help us in reusing our code. They make our code modular. In this article, we have discussed about kinds of Swift functions and how we use them. We have seen how to declare and use these functions based on our requirements. We\u2019ve learnt about different combinations of functions with and without parameters and return values. We have also gone through different kinds of parameters defined in Swift.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Functions are reusable blocks of code in a program. It performs a specific task like addition or printing or even some other complex task. It might take parameters, and it might also return values.&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":120679,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27789],"tags":[28455,28456,21771,28454,28287],"class_list":["post-120677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift-tutorials","tag-functions-in-swift","tag-kinds-of-function","tag-swift","tag-swift-functions","tag-swift-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift Functions with Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"Swift Functions help us in reusing our code. In this article, we have discussed about kinds of functions and how we use them.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/swift-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift Functions with Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Swift Functions help us in reusing our code. In this article, we have discussed about kinds of functions and how we use them.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/swift-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-21T12:30:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T12:54:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift Functions with Examples - DataFlair","description":"Swift Functions help us in reusing our code. In this article, we have discussed about kinds of functions and how we use them.","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:\/\/data-flair.training\/blogs\/swift-functions\/","og_locale":"en_US","og_type":"article","og_title":"Swift Functions with Examples - DataFlair","og_description":"Swift Functions help us in reusing our code. In this article, we have discussed about kinds of functions and how we use them.","og_url":"https:\/\/data-flair.training\/blogs\/swift-functions\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-11-21T12:30:39+00:00","article_modified_time":"2023-11-21T12:54:37+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Swift Functions with Examples","datePublished":"2023-11-21T12:30:39+00:00","dateModified":"2023-11-21T12:54:37+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/"},"wordCount":1029,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp","keywords":["functions in swift","kinds of function","Swift","swift functions","swift tutorials"],"articleSection":["Swift Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/swift-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/","url":"https:\/\/data-flair.training\/blogs\/swift-functions\/","name":"Swift Functions with Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp","datePublished":"2023-11-21T12:30:39+00:00","dateModified":"2023-11-21T12:54:37+00:00","description":"Swift Functions help us in reusing our code. In this article, we have discussed about kinds of functions and how we use them.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/swift-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/swift-functions.webp","width":1200,"height":628,"caption":"swift functions"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/swift-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Swift Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/swift-tutorials\/"},{"@type":"ListItem","position":3,"name":"Swift Functions with Examples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=120677"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120677\/revisions"}],"predecessor-version":[{"id":126570,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/120677\/revisions\/126570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/120679"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=120677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=120677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=120677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}