

{"id":13582,"date":"2018-04-17T04:44:02","date_gmt":"2018-04-17T04:44:02","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=13582"},"modified":"2021-12-04T10:16:26","modified_gmt":"2021-12-04T04:46:26","slug":"scala-function","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/scala-function\/","title":{"rendered":"Scala Function Tutorial &#8211; Types of Functions in Scala"},"content":{"rendered":"<p>In this tutorial, we will discuss some Scala Functions. Moreover, we will study how to define and declare functions in Scala. Along with this, we will learn how to call your own Scala function. At last, we will cover different types of Scala Functions.<\/p>\n<p>So, let&#8217;s start the Scala Function Tutorial.<\/p>\n<h3>What is Scala Function?<\/h3>\n<p>When we want to execute a group of statements to perform a task a hundred times, we don\u2019t type them a hundred times. We group them into a function, put a call to that function inside a loop, and make that loop run a hundred times.<\/p>\n<p>Well, dividing our code into functions also makes for modularity &#8211; it makes it easier to debug and modify the code. We can do this division according to the tasks we carry out in our code.<\/p>\n<p>Scala is rich with built-in functions, and it also lets us create our own. Here, Scala function is first-class value.<\/p>\n<p>Scala also has methods, but these differ only slightly from Scala function. A method belongs to a class; it has a name, a signature, [optionally, ] some annotations, and some bytecode. A function is a complete object that we can store in a variable. Then, a method is a function that is a member of some object. You can also learn<a href=\"https:\/\/data-flair.training\/blogs\/scala-variable\/\"> Scala Variable <\/a>and Other Scala tutorials from our blog long with Scala Functions.<\/p>\n<h3>Declaring a Function in Scala<\/h3>\n<p>To create a Scala function, we use the keyword \u2018def\u2019.<\/p>\n<h4>a. Syntax<\/h4>\n<p>Here\u2019s the syntax you\u2019ll want to follow:<\/p>\n<pre class=\"EnlighterJSRAW\">def functionName(parameters:typeofparameters):returntypeoffunction={\r\n\/\/statements to be executed\r\n}<\/pre>\n<p>Now here, while you must mention the types of parameters, the type of Scala function is optional. What else is optional is the \u2018=\u2019 operator. Let\u2019s see examples for each kind of declaration.<\/p>\n<h4>b. Without = | Without Parameters<\/h4>\n<p>You can consider this to be the simplest kind of Scala function declaration.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sayhello(){\r\n    | println(\"Hello\")\r\n    | }\r\nsayhello: ()Unit\r\n<\/pre>\n<p>Now, let\u2019s call it.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; sayhello()<\/pre>\n<p>Hello<br \/>\nAs you can see, since we make this function return nothing, it returns Unit. All that this Scala function does is take no parameters and simply print Hello.<\/p>\n<h4>c. Without = | With Parameters<\/h4>\n<p>We can declare a Scala function that takes parameters to work on to produce a result. Here, we simply print that result instead of returning it.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sum(a:Int,b:Int)\r\n    | {\r\n    | println(a+b)\r\n    | }\r\nsum: (a: Int, b: Int)Unit\r\nscala&gt; sum(2,5)<\/pre>\n<p>7<br \/>\nThis code prints the sum of two integers. By default, this Scala function returns Unit.<\/p>\n<h4>d. With = | Without Parameters<\/h4>\n<p>With the = operator, a function takes a return type, and also returns a value of that type.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func():Int={\r\n    | return 7\r\n    | }\r\nfunc: ()Int\r\nIn Scala, if you type in the same commands again, it will detect that:\r\nscala&gt; scala&gt; def func():Int={\r\n\/\/ Detected repl transcript. Paste more, or ctrl-D to finish.\r\n | return 7\r\n    | }\r\nfunc: ()Int<\/pre>\n<p>To break out of this, press Ctrl+D.<br \/>\n\/\/ Replaying 1 commands from transcript.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func():Int={\r\nreturn 7\r\n}\r\nfunc: ()Int\r\nscala&gt;<\/pre>\n<p>Note that this, however, wouldn\u2019t work:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func()={\r\n    | return 7\r\n    | }\r\n&lt;console&gt;:15: error: method func has return statement; needs result type\r\n      return 7\r\n      ^<\/pre>\n<h4>e. With = | With Parameters<\/h4>\n<p>Let\u2019s try defining a Scala function to work on some parameters to return a result.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sum(a:Int,b:Int):Int={\r\n    | return a+b\r\n    | }\r\nsum: (a: Int, b: Int)Int\r\nscala&gt; sum(2,5)\r\nres22: Int = 7<\/pre>\n<p>This would\u2019ve worked too:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sum(a:Int,b:Int):Int={\r\n    | println(\"Adding\")\r\n    | a+b\r\n    | }\r\nsum: (a: Int, b: Int)Int\r\nscala&gt; sum(2,5)\r\nAdding\r\nres23: Int = 7<\/pre>\n<p>This means that a function will return the value of the expression right before the closing curly brace; the \u2018return\u2019 keyword isn\u2019t necessary.<\/p>\n<p><strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/scala-data-types\/\">Scala DataTypes with Syntax and Examples<\/a><\/strong><\/p>\n<h3>Recursion in Scala Function<\/h3>\n<p>A Scala function involves in recursion when it makes a call to itself. Let\u2019s take an example:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def factorial(n:Int):Int={\r\n   | if(n==1)\r\n    | {\r\n    | return 1\r\n    | }\r\n    | n*factorial(n-1)\r\n    | }\r\nfactorial: (n: Int)Int\r\nscala&gt; factorial(6)\r\nres0: Int = 720\r\nscala&gt; factorial(1)\r\nres1: Int = 1\r\nscala&gt; factorial(4)\r\nres2: Int = 24\r\nscala&gt; factorial(10)\r\nres4: Int = 3628800<\/pre>\n<p>This Scala\u00a0 function correctly calculates the factorial of an integer one or greater.<br \/>\n<strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/scala-comments\/\">Scala Comments with Syntax and Example<\/a><\/strong><\/p>\n<h3>Default Arguments in Scala<\/h3>\n<p>If we elide an argument in a function call, Scala will take the default value we provided for it.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func(a:Int,b:Int=7){\r\n    | println(a*b)\r\n    | }\r\nfunc: (a: Int, b: Int)Unit\r\nscala&gt; func(2,5)\r\n10\r\nscala&gt; func(2)<\/pre>\n<p>14<br \/>\nBut make sure that any default arguments must be after all non-default arguments. The following code raises an error:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func(a:Int=7,b:String){\r\n    | println(s\"$a $b\")\r\n    | }\r\nfunc: (a: Int, b: String)Unit\r\nscala&gt; func(\"Ayushi\")\r\n&lt;console&gt;:13: error: not enough arguments for method func: (a: Int, b: String)Unit.\r\nUnspecified value parameter b.\r\n      func(\"Ayushi\")\r\n          ^<\/pre>\n<p><strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/scala-string\/\">Scala String: Creating String, Concatenation, String Length<\/a><\/strong><\/p>\n<h3>Scala Named Arguments<\/h3>\n<p>When we want to pass arguments to a Scala function in a different order, we can pass them with names:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def diff(a:Int,b:Int):Int={\r\n    | return b-a\r\n    | }\r\ndiff: (a: Int, b: Int)Int\r\nscala&gt; diff(2,3)\r\nres12: Int = 1\r\nscala&gt; diff(b=3,a=2)\r\nres13: Int = 1<\/pre>\n<p><strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/scala-array\/\">Scala Arrays and Multidimensional Arrays in Scala<\/a><\/strong><\/p>\n<h3>Scala Functions with Variable Arguments<\/h3>\n<p>When we don\u2019t know how many arguments we\u2019ll want to pass, we can use a variable argument for this:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sum(args:Int*):Int={\r\n    | var result=0\r\n    | for(arg&lt;-args){\r\n    | result+=arg\r\n    | }\r\n    | result}\r\nsum: (args: Int*)Int\r\nLet\u2019s try calling this with different number of arguments.\r\nscala&gt; sum(1)\r\nres0: Int = 1\r\nscala&gt; sum(2,3)\r\nres1: Int = 5\r\nscala&gt; sum(4,5,2,7)\r\nres2: Int = 18<\/pre>\n<h3>Higher-Order Functions in Scala<\/h3>\n<p>Since Scala is a highly functional language, it treats its functions as first-class citizens. This means that we can pass them around as parameters, or even return them from functions.<\/p>\n<p>Let\u2019s first define a Scala function sayhello:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sayhello(s:String){\r\n    | println(s\"Hello, $s\")\r\n    | }\r\nsayhello: (s: String)Unit\r\nSuppose we have a string \u2018name\u2019:\r\nscala&gt; val name:String=\"Ayushi\"\r\nname: String = Ayushi<\/pre>\n<p>Now, let\u2019s define a function func that calls \u2018sayhello\u2019 on \u2018name\u2019.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def func(f:String=&gt;Unit,s:String){\r\n    | f(s)\r\n    | }\r\nfunc: (f: String =&gt; Unit, s: String)Unit\r\nscala&gt; func(sayhello,name)<\/pre>\n<p>Hello, Ayushi<br \/>\nIn this example, we used a Scala function as a parameter to another.<\/p>\n<p><strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/tuples-in-scala-introduction\/\">Tuples in Scala \u2013 A Quick Introduction<\/a><\/strong><\/p>\n<h3>Nested Functions in Scala<\/h3>\n<p>With Scala, we can define a Scala function inside another. This is what a local function looks like:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def outer(){\r\n    | println(\"In outer\")\r\n    | def inner(){\r\n    | println(\"In inner\")\r\n    | }\r\n    | inner()\r\n    | }\r\nouter: ()Unit\r\nscala&gt; outer()<\/pre>\n<p>In outer<br \/>\nIn inner<br \/>\nLet\u2019s take another example.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def outer(a:Int){\r\n    | println(\"In outer\")\r\n    | def inner(){\r\n    | println(a*3)\r\n    | }\r\n    | inner()\r\n    | }\r\nouter: (a: Int)Unit\r\nNow, let\u2019s call it:\r\nscala&gt; outer(3)<\/pre>\n<p>In outer<br \/>\n9<\/p>\n<p class=\"entry-title \"><strong>Learn: <a href=\"https:\/\/data-flair.training\/blogs\/scala-closures\/\">Scala Closures with Examples | See What is Behind the Magic<\/a><\/strong><\/p>\n<h3>Scala Anonymous Functions<\/h3>\n<p>Anonymous functions in Scala is the lightweight syntax to create a function in one line of code. We\u2019ve been using this in our articles so far. Anonymous functions are functioning literals, and at runtime, they instantiate into objects called function values.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; val sum=(a:Int,b:Int)=&gt;a+b\r\nsum: (Int, Int) =&gt; Int = $$Lambda$1116\/1013657610@5bdb6ea8\r\nscala&gt; sum(2,3)\r\nres3: Int = 5\r\n<\/pre>\n<p>Let&#8217;s take another Example.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; val x=()=&gt;println(\"Hello\")\r\nx: () =&gt; Unit = $$Lambda$1122\/1244890076@72ce8a9b\r\nscala&gt; x()<\/pre>\n<p>Hello<\/p>\n<h3>Scala Currying Functions<\/h3>\n<p>If a Scala function takes multiple parameters, we can transform it into a chain of functions where each takes a single parameter. We use multiple parameter lists for curried functions.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; def sum(a:Int)(b:Int)={\r\n    | a+b\r\n    | }\r\nsum: (a: Int)(b: Int)Int\r\nscala&gt; sum(2)(5)<\/pre>\n<p>res3: Int = 7<\/p>\n<p>So, this was all about Scala Functions. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this blog, we discussed Scala functions, recursion, and default, named, and variable arguments. We also learned about higher-order functions, nested functions, anonymous functions, and carrying.<\/p>\n<p><strong><a href=\"http:\/\/docs.scala-lang.org\/tutorials\/tour\/higher-order-functions.html.html\">Reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1978,&quot;href&quot;:&quot;http:\\\/\\\/docs.scala-lang.org\\\/tutorials\\\/tour\\\/higher-order-functions.html.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20180414051546\\\/http:\\\/\\\/docs.scala-lang.org:80\\\/tutorials\\\/tour\\\/higher-order-functions.html.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 14:58:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-07 07:24:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-19 04:01:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-06 05:15:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 04:23:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 06:12:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 10:04:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 20:01:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-22 12:38:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-27 09:21:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-04 05:57:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-07 11:59:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-22 05:15:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-27 10:08:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-03 09:13:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-19 07:32:25&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-06-28 10:51:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-02 03:07:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-05 15:55:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-10 11:48:07&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-07-14 03:11:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-18 21:11:04&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-07-18 21:11:04&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will discuss some Scala Functions. Moreover, we will study how to define and declare functions in Scala. Along with this, we will learn how to call your own Scala function.&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":13595,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[5645,9036,12465,12538,15336],"class_list":["post-13582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scala","tag-higher-order-scala-functions","tag-nested-functions-in-scala","tag-scala-functions","tag-scala-recursion","tag-variable-arguments-in-scala"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scala Function Tutorial - Types of Functions in Scala - DataFlair<\/title>\n<meta name=\"description\" content=\"What is Scala Function- Types of Functions in Scala, Declare Scala Function, Scala Currying, Anonymous,Nested,Higher-Order Named Arguments in Scala\" \/>\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\/scala-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scala Function Tutorial - Types of Functions in Scala - DataFlair\" \/>\n<meta property=\"og:description\" content=\"What is Scala Function- Types of Functions in Scala, Declare Scala Function, Scala Currying, Anonymous,Nested,Higher-Order Named Arguments in Scala\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/scala-function\/\" \/>\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=\"2018-04-17T04:44:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-04T04:46:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg\" \/>\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\/jpeg\" \/>\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=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scala Function Tutorial - Types of Functions in Scala - DataFlair","description":"What is Scala Function- Types of Functions in Scala, Declare Scala Function, Scala Currying, Anonymous,Nested,Higher-Order Named Arguments in Scala","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\/scala-function\/","og_locale":"en_US","og_type":"article","og_title":"Scala Function Tutorial - Types of Functions in Scala - DataFlair","og_description":"What is Scala Function- Types of Functions in Scala, Declare Scala Function, Scala Currying, Anonymous,Nested,Higher-Order Named Arguments in Scala","og_url":"https:\/\/data-flair.training\/blogs\/scala-function\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-04-17T04:44:02+00:00","article_modified_time":"2021-12-04T04:46:26+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Scala Function Tutorial &#8211; Types of Functions in Scala","datePublished":"2018-04-17T04:44:02+00:00","dateModified":"2021-12-04T04:46:26+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/"},"wordCount":887,"commentCount":2,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg","keywords":["higher-order Scala functions","nested functions in Scala","Scala functions","Scala recursion","variable arguments in Scala"],"articleSection":["Scala Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/scala-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/scala-function\/","url":"https:\/\/data-flair.training\/blogs\/scala-function\/","name":"Scala Function Tutorial - Types of Functions in Scala - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg","datePublished":"2018-04-17T04:44:02+00:00","dateModified":"2021-12-04T04:46:26+00:00","description":"What is Scala Function- Types of Functions in Scala, Declare Scala Function, Scala Currying, Anonymous,Nested,Higher-Order Named Arguments in Scala","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/scala-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Functions-in-Scala-01.jpg","width":1200,"height":628,"caption":"Scala Functions"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/scala-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Scala Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/scala\/"},{"@type":"ListItem","position":3,"name":"Scala Function Tutorial &#8211; Types of Functions in Scala"}]},{"@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\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13582","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\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=13582"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13582\/revisions"}],"predecessor-version":[{"id":104785,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/13582\/revisions\/104785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/13595"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=13582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=13582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=13582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}