{"id":925,"date":"2022-08-17T20:21:47","date_gmt":"2022-08-17T20:21:47","guid":{"rendered":"https:\/\/datmt.com\/?p=925"},"modified":"2022-08-17T20:21:48","modified_gmt":"2022-08-17T20:21:48","slug":"scala-variables-tutorial","status":"publish","type":"post","link":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/","title":{"rendered":"Scala Variables Tutorial"},"content":{"rendered":"\n<p>Declaring variables in Scala is quite simple. The language offers some very nice mechanisms to let developers declare variables with ease.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mutable variables<\/h2>\n\n\n\n<p>To declare mutable variables (variables that you can assign to a different value after declaring), you need to use the keyword <code>var<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">  def mutableVariable(): Unit =\n    var x = 100;\n    println(s&quot;x is: ${x}&quot;)\n    x = 200\n    println(s&quot;x is: ${x}&quot;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Immutable variables<\/h2>\n\n\n\n<p>To declare immutable variables, instead of using <code>var<\/code>, you need to use <code>val<\/code><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">  def immutableVariable(): Unit =\n    val x = 100\n<\/pre><\/div>\n\n\n\n<p>Trying to assign x to another value would cause a compiler error:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">\n  def immutableVariable(): Unit =\n    val x = 100\n    x = 100 \/\/&lt;- this would cause a compiler error<\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"408\" height=\"142\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" src=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-73.png\" alt=\"Build failed due to immutable variable reassignment\" class=\"wp-image-926\" srcset=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-73.png 408w, https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-73-300x104.png 300w\" \/><figcaption>Build failed due to immutable variable reassignment<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Type inference<\/h2>\n\n\n\n<p>As you can see from the examples above, I declared variables without specifying the types. This is not because Scala is a loosely typed language like Javascript. Instead, it infers the type based on the value you assign to the variables.<\/p>\n\n\n\n<p>You can specify the type of the variables if you want to. <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">  def typeInference(): Unit =\n\n   val dog1 = GSD_Dog(&quot;Joe&quot;)\n    println(&quot;type of dog1: &quot; + dog1.getClass)\n\n    val x : String = &quot;hello&quot;\n    println(&quot;type of x: &quot; + x.getClass)\n\n    var m = 100f\n    println(&quot;type of m: &quot; + m.getClass)\n\n    var n = 100\n    println(&quot;type of n: &quot; + n.getClass)\n<\/pre><\/div>\n\n\n\n<p>Calling this function produces the following results:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"842\" height=\"314\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" src=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-75.png\" alt=\"Type inference in Scala\" class=\"wp-image-928\" srcset=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-75.png 842w, https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-75-300x112.png 300w, https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-75-768x286.png 768w\" \/><figcaption>Type inference in Scala<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Multiple variables declaration<\/h2>\n\n\n\n<p>You can declare multiple variables (mutable and immutable on one line) like this:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">  def multipleVariableDeclaration(): Unit =\n    var (x: Int, y: String, z: Boolean) = (100, &quot;Hello&quot;, false)\n    println(s&quot;x = $x, y = $y, z = $z&quot;)\n<\/pre><\/div>\n\n\n\n<p>Calling the function would produce the correct values for x, y, z respectively:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"277\" sizes=\"auto, (max-width: 855px) 100vw, 855px\" src=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-74.png\" alt=\"Multiple variables declaration\" class=\"wp-image-927\" srcset=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-74.png 855w, https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-74-300x97.png 300w, https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/image-74-768x249.png 768w\" \/><figcaption>Multiple variables declaration<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Variable scopes<\/h2>\n\n\n\n<p>There are three variable scopes in Scala:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Field (class variable)<\/li><li>Method parameters (arguments passed to methods)<\/li><li>Local (variables declared inside methods)<\/li><\/ul>\n\n\n\n<p>Here is the example of the scopes:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-scala&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Scala&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;scala&quot;}\">case class GSD_Dog(name: String) {\n  val breed: String = &quot;GSD&quot;\n  \n  def reportState(isSleeping: Boolean = true): Unit =\n    var report = &quot;Not sleeping&quot;\n    if (isSleeping) then\n      report = &quot;I'm busy&quot;\n      \n    println(report)\n}<\/pre><\/div>\n\n\n\n<p>In this example,<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> <code>breed<\/code> has field scope.<\/li><li><code>isSleeping<\/code> has method parameters scope<\/li><li><code>report<\/code> has local variable scopes<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this post, I&#8217;ve introduced you to Scala variables. To recap, variables in Scala can be mutable or immutable. When declaring variables, you can specify their types or leave for type inference to do the work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Declaring variables in Scala is quite simple. The language offers some very nice mechanisms to let developers declare variables with ease.<\/p>\n","protected":false},"author":1,"featured_media":929,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[124],"tags":[127,131,132],"class_list":["post-925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scala","tag-scala","tag-scala-tutorial","tag-scala-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scala Variables Tutorial - datmt<\/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:\/\/datmt.com\/scala\/scala-variables-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scala Variables Tutorial - datmt\" \/>\n<meta property=\"og:description\" content=\"Declaring variables in Scala is quite simple. The language offers some very nice mechanisms to let developers declare variables with ease.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"datmt\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-17T20:21:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-17T20:21:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.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=\"\u0110\u1ea1t Tr\u1ea7n\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u0110\u1ea1t Tr\u1ea7n\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\"},\"author\":{\"name\":\"\u0110\u1ea1t Tr\u1ea7n\",\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e\"},\"headline\":\"Scala Variables Tutorial\",\"datePublished\":\"2022-08-17T20:21:47+00:00\",\"dateModified\":\"2022-08-17T20:21:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\"},\"wordCount\":259,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e\"},\"image\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg\",\"keywords\":[\"scala\",\"scala tutorial\",\"Scala Variables\"],\"articleSection\":[\"scala\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\",\"url\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\",\"name\":\"Scala Variables Tutorial - datmt\",\"isPartOf\":{\"@id\":\"https:\/\/datmt.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg\",\"datePublished\":\"2022-08-17T20:21:47+00:00\",\"dateModified\":\"2022-08-17T20:21:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage\",\"url\":\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg\",\"contentUrl\":\"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg\",\"width\":1200,\"height\":628,\"caption\":\"Scala Variables Tutorial\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/datmt.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Scala Variables Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/datmt.com\/#website\",\"url\":\"https:\/\/datmt.com\/\",\"name\":\"datmt\",\"description\":\"Hands on projects\",\"publisher\":{\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/datmt.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e\",\"name\":\"\u0110\u1ea1t Tr\u1ea7n\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/datmt.com\/wp-content\/uploads\/2023\/03\/cropped-profile.jpg\",\"contentUrl\":\"https:\/\/datmt.com\/wp-content\/uploads\/2023\/03\/cropped-profile.jpg\",\"width\":512,\"height\":512,\"caption\":\"\u0110\u1ea1t Tr\u1ea7n\"},\"logo\":{\"@id\":\"https:\/\/datmt.com\/#\/schema\/person\/image\/\"},\"description\":\"I build softwares that solve problems. I also love writing\/documenting things I learn\/want to learn.\",\"sameAs\":[\"https:\/\/datmt.com\"],\"url\":\"https:\/\/datmt.com\/author\/mtdat171_c\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scala Variables Tutorial - datmt","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:\/\/datmt.com\/scala\/scala-variables-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Scala Variables Tutorial - datmt","og_description":"Declaring variables in Scala is quite simple. The language offers some very nice mechanisms to let developers declare variables with ease.","og_url":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/","og_site_name":"datmt","article_published_time":"2022-08-17T20:21:47+00:00","article_modified_time":"2022-08-17T20:21:48+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg","type":"image\/jpeg"}],"author":"\u0110\u1ea1t Tr\u1ea7n","twitter_card":"summary_large_image","twitter_misc":{"Written by":"\u0110\u1ea1t Tr\u1ea7n","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#article","isPartOf":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/"},"author":{"name":"\u0110\u1ea1t Tr\u1ea7n","@id":"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e"},"headline":"Scala Variables Tutorial","datePublished":"2022-08-17T20:21:47+00:00","dateModified":"2022-08-17T20:21:48+00:00","mainEntityOfPage":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/"},"wordCount":259,"commentCount":0,"publisher":{"@id":"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e"},"image":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg","keywords":["scala","scala tutorial","Scala Variables"],"articleSection":["scala"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/","url":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/","name":"Scala Variables Tutorial - datmt","isPartOf":{"@id":"https:\/\/datmt.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg","datePublished":"2022-08-17T20:21:47+00:00","dateModified":"2022-08-17T20:21:48+00:00","breadcrumb":{"@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/datmt.com\/scala\/scala-variables-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#primaryimage","url":"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg","contentUrl":"https:\/\/datmt.com\/wp-content\/uploads\/2022\/08\/Scala-Variables-Tutorial.jpg","width":1200,"height":628,"caption":"Scala Variables Tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/datmt.com\/scala\/scala-variables-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/datmt.com\/"},{"@type":"ListItem","position":2,"name":"Scala Variables Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/datmt.com\/#website","url":"https:\/\/datmt.com\/","name":"datmt","description":"Hands on projects","publisher":{"@id":"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/datmt.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/datmt.com\/#\/schema\/person\/7736566e3758f424a11fd53f581c4b5e","name":"\u0110\u1ea1t Tr\u1ea7n","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/datmt.com\/#\/schema\/person\/image\/","url":"https:\/\/datmt.com\/wp-content\/uploads\/2023\/03\/cropped-profile.jpg","contentUrl":"https:\/\/datmt.com\/wp-content\/uploads\/2023\/03\/cropped-profile.jpg","width":512,"height":512,"caption":"\u0110\u1ea1t Tr\u1ea7n"},"logo":{"@id":"https:\/\/datmt.com\/#\/schema\/person\/image\/"},"description":"I build softwares that solve problems. I also love writing\/documenting things I learn\/want to learn.","sameAs":["https:\/\/datmt.com"],"url":"https:\/\/datmt.com\/author\/mtdat171_c\/"}]}},"_links":{"self":[{"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/posts\/925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/comments?post=925"}],"version-history":[{"count":1,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/posts\/925\/revisions"}],"predecessor-version":[{"id":930,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/posts\/925\/revisions\/930"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/media\/929"}],"wp:attachment":[{"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/media?parent=925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/categories?post=925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datmt.com\/wp-json\/wp\/v2\/tags?post=925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}