

{"id":11696,"date":"2018-03-24T09:46:14","date_gmt":"2018-03-24T09:46:14","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=11696"},"modified":"2021-12-04T10:16:44","modified_gmt":"2021-12-04T04:46:44","slug":"scala-if-else-statements","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/","title":{"rendered":"Scala if else Statements &#8211; if, if-else if-else, Nested if-else Statements"},"content":{"rendered":"<p>Decision making is an important part of any programming language. For this purpose, we have if-else statements. Let\u2019s see how Scala if else works. Before that, you can refer our previous article on <strong><a href=\"https:\/\/data-flair.training\/blogs\/scala-control-structures-comprehensive-guide\/\">Scala Control Statements<\/a>.<\/strong><\/p>\n<p>We will start with Scala if Statements, Scala if else Statements, Scala if else &#8211; if &#8211; else statements and nested if else statements with their syntax &amp; examples.<\/p>\n<p>So, let&#8217;s start Scala if else Statements.<\/p>\n<h3>Scala if Statement<\/h3>\n<p>We begin with the Scala if statement. This statement evaluates an expression. If true, it executes the block of statements under it.<\/p>\n<h4>a. Syntax<\/h4>\n<p>Take a look at the syntax:<\/p>\n<pre class=\"EnlighterJSRAW\">if(Boolean_expression)\r\n{\r\n\/\/Code to execute if expression is true\r\n}<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/scala-thread\/\">Do you know What is Scala Thread &amp; Multithreading?<\/a><\/strong><\/p>\n<p>If the Boolean expression evaluates to true, the block of code under the if-statement executes. Otherwise, the code right after the code block under the if-statement executes.<\/p>\n<div id=\"attachment_34468\" style=\"width: 415px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_statement.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-34468\" class=\"wp-image-34468 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_statement.jpg\" alt=\"Scala if else Statements - if, if-else if-else, Nested if-else Statements\" width=\"405\" height=\"502\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_statement.jpg 405w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_statement-121x150.jpg 121w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_statement-242x300.jpg 242w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/a><p id=\"caption-attachment-34468\" class=\"wp-caption-text\">Scala if Statements<\/p><\/div>\n<h4>b. Scala if Example<\/h4>\n<p>Okay, let\u2019s do an example.<br \/>\nobject Main extends App<\/p>\n<pre class=\"EnlighterJSRAW\">{\r\n    val x=7\r\n    if(x&lt;10)\r\n    {\r\n        println(\"Woohoo!\")\r\n    }\r\n}<\/pre>\n<p>And here\u2019s the output:<br \/>\nWoohoo!<\/p>\n<p><strong>Read:<a href=\"https:\/\/data-flair.training\/blogs\/tuples-in-scala-introduction\/\"> Tuples in Scala<\/a><\/strong><\/p>\n<h3>Scala if-else Statement<\/h3>\n<p>What to do if the expression turns out to be false? Execute the code under the else statement.<\/p>\n<h4>a. Syntax<\/h4>\n<p>For an if-else statement, follow this syntax:<\/p>\n<pre class=\"EnlighterJSRAW\">if(Boolean_expression)\r\n{\r\n\/\/Code to execute if expression is true\r\n}\r\nelse\r\n{\r\n\/\/Code to execute if expression is false\r\n}<\/pre>\n<div id=\"attachment_34469\" style=\"width: 261px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_else_statement.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-34469\" class=\"size-full wp-image-34469\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_else_statement.jpg\" alt=\"Scala if else Statements - if, if-else if-else, Nested if-else Statements\" width=\"251\" height=\"321\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_else_statement.jpg 251w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_else_statement-117x150.jpg 117w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if_else_statement-235x300.jpg 235w\" sizes=\"auto, (max-width: 251px) 100vw, 251px\" \/><\/a><p id=\"caption-attachment-34469\" class=\"wp-caption-text\">Scala if else Statements<\/p><\/div>\n<h4>b. Scala if else example<\/h4>\n<p>Let\u2019s take an example.<br \/>\nobject Main extends App<\/p>\n<pre class=\"EnlighterJSRAW\">{\r\n    val x=17\r\n    if(x&lt;10)\r\n    {\r\n        println(\"Woohoo!\")\r\n    }\r\n    else\r\n    {\r\n        println(\"Oh no!\")\r\n    }\r\n}<\/pre>\n<p>And the output is:<br \/>\nOh no!<br \/>\n<strong>Read:<a href=\"https:\/\/data-flair.training\/blogs\/partial-functions-scala-guide\/\"> Scala Partial Functions<\/a><\/strong><\/p>\n<h3>Scala if-else if-else Statement<\/h3>\n<p>When we want to check another condition when one fails, and yet another when that one fails, and so on, we can use this. One \u2018if\u2019 statement can have any number of \u2018else if\u2019 statements. But remember to end these with a final \u2018else\u2019 statement.<\/p>\n<h4>a. Syntax<\/h4>\n<p>Follow this syntax:<\/p>\n<pre class=\"EnlighterJSRAW\">if(Boolean_expression 1)\r\n{\r\n\/\/Code to execute if expression 1 is true\r\n}\r\nelse if(Boolean_expression 2)\r\n{\r\n\/\/Code to execute if expression 2 is true; checked only when expression 1 is false\r\n}\r\nelse if(Boolean_expression 3)\r\n{\r\n\/\/Code to execute if expression 3 is true; checked only when expression 2 is false\r\n}\r\nelse\r\n{\r\n\/\/Code to execute if expression 3 is false\r\n<\/pre>\n<div id=\"attachment_34470\" style=\"width: 761px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-34470\" class=\"size-full wp-image-34470\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else.jpg\" alt=\"Scala if else Statements - if, if-else if-else, Nested if-else Statements\" width=\"751\" height=\"700\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else.jpg 751w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else-150x140.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else-300x280.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/if-else-if-else-520x485.jpg 520w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/a><p id=\"caption-attachment-34470\" class=\"wp-caption-text\">Scala if-else if-else Statements<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/scala-extractors\/\">Have a look at &#8211; Extractors vs Case Classes<\/a><\/strong><\/p>\n<h4>b. Scala if else if else example<\/h4>\n<p>Time for an example.<br \/>\nobject Main extends App<\/p>\n<pre class=\"EnlighterJSRAW\">{\r\n    val x=17\r\n    if(x&lt;10)\r\n    {\r\n        println(\"Woohoo!\")\r\n    }\r\n    else if(x&lt;20)\r\n    {\r\n        println(\"Okay\")\r\n    }\r\n    else\r\n    {\r\n        println(\"Oh no!\")\r\n    }\r\n}<\/pre>\n<p>And who\u2019s guessing the output?<br \/>\nOkay<br \/>\n<strong>Read:<a href=\"https:\/\/data-flair.training\/blogs\/pros-and-cons-of-scala\/\"> Pros and Cons of Scala<\/a><\/strong><\/p>\n<h3>Scala Nested if-else Statement<\/h3>\n<p>You can put an \u2018if\u2019 or \u2018else if\u2019 statement inside another \u2018if\u2019 or \u2018else if\u2019 statement. Full flexibility!<\/p>\n<h4>a. Syntax<\/h4>\n<p>Follow this syntax:<\/p>\n<pre class=\"EnlighterJSRAW\">if(Boolean_expression 1)\r\n{\r\n\/\/Code to execute if expression 1 is true\r\nif(Boolean_expression 2)\r\n{\r\n\/\/Code to execute if expression 2 is true\r\n}\r\nelse\r\n{\r\n    \/\/Code to execute if expression 2 is false\r\n}\r\n}\r\nelse\r\n{\r\n    \/\/Code to execute if expression 1 is false\r\n<\/pre>\n<div id=\"attachment_34471\" style=\"width: 587px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/nested-if.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-34471\" class=\"size-full wp-image-34471\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/nested-if.gif\" alt=\"Scala if else Statements - if, if-else if-else, Nested if-else Statements\" width=\"577\" height=\"503\" \/><\/a><p id=\"caption-attachment-34471\" class=\"wp-caption-text\">Scala Nested if-else Statements<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/scala-throw-keyword\/\">Do you know How Can We Use Scala Throw Keyword?<\/a><\/strong><\/p>\n<h4>b. Scala Nested If Else Example<\/h4>\n<p>Let\u2019s take an example for this.<br \/>\nobject Main extends App<\/p>\n<pre class=\"EnlighterJSRAW\">{\r\n    val x=7\r\n    if(x&lt;10)\r\n    {\r\n        println(\"Woohoo!\")\r\n        if(x&lt;5)\r\n        {\r\n            println(\"Hi\")\r\n        }\r\n        else\r\n        {\r\n            println(\"Bye\")\r\n        }\r\n    }\r\n    else\r\n    {\r\n        println(\"Oh no!\")\r\n    }\r\n}<\/pre>\n<p>And the output is:<br \/>\nWoohoo!<br \/>\nBye<\/p>\n<p>So, this was all about Scala If Else Statements. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this lesson, we learned about Scala if, Scala if else, Scala if-else if-else, and Scala nested if statements with their syntax and examples. Furthermore, if you have any query, feel free to ask in the comment box.<\/p>\n<p>Related Topic &#8211;<strong><a href=\"https:\/\/data-flair.training\/blogs\/scala-while-loop\/\"> Scala While Loop<\/a><\/strong><\/p>\n<p><strong><a href=\"https:\/\/www.scala-lang.org\/\">Reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1904,&quot;href&quot;:&quot;https:\\\/\\\/www.scala-lang.org&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251206135355\\\/https:\\\/\\\/www.scala-lang.org\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 07:41:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-15 07:30:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-18 15:55:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-23 02:56:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-27 16:24:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-02 02:40:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-05 13:44:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-09 08:06:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 14:24:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-17 17:26:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-20 17:57:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-24 15:52:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-30 14:21:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-02 14:58:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-05 16:39:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 17:17:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 04:52:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 13:39:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 17:10:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 04:44:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 07:25:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 21:46:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 18:02:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-27 20:15:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 11:05:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 19:22:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 07:59:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 16:14:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 23:18:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-26 09:13:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-29 14:23:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-07 12:16:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-13 10:20:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-18 15:54:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-22 05:55:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-25 08:30:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-29 13:12:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-02 14:06:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-09 18:23:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-15 16:29:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-19 06:54:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-22 13:14:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-26 04:09:02&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-29 09:04:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-03 02:40:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-06 20:59:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-09 23:42:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-13 10:49:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-07-16 22:33:30&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-07-16 22:33:30&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Decision making is an important part of any programming language. For this purpose, we have if-else statements. Let\u2019s see how Scala if else works. Before that, you can refer our previous article on Scala&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":31295,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[6449,16592,12469,12471],"class_list":["post-11696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scala","tag-if-else-if-statement-scala","tag-scala-decision-making","tag-scala-if","tag-scala-if-else-alternative"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scala if else Statements - if, if-else if-else, Nested if-else Statements - DataFlair<\/title>\n<meta name=\"description\" content=\"Scala if else Statements,Scala if Statement,Scala if-else if-else Statement, Scala Nested if-else Statement, With examples and syntax, Scala Decision Making\" \/>\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-if-else-statements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scala if else Statements - if, if-else if-else, Nested if-else Statements - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Scala if else Statements,Scala if Statement,Scala if-else if-else Statement, Scala Nested if-else Statement, With examples and syntax, Scala Decision Making\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/\" \/>\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-03-24T09:46:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-04T04:46:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.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=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scala if else Statements - if, if-else if-else, Nested if-else Statements - DataFlair","description":"Scala if else Statements,Scala if Statement,Scala if-else if-else Statement, Scala Nested if-else Statement, With examples and syntax, Scala Decision Making","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-if-else-statements\/","og_locale":"en_US","og_type":"article","og_title":"Scala if else Statements - if, if-else if-else, Nested if-else Statements - DataFlair","og_description":"Scala if else Statements,Scala if Statement,Scala if-else if-else Statement, Scala Nested if-else Statement, With examples and syntax, Scala Decision Making","og_url":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-24T09:46:14+00:00","article_modified_time":"2021-12-04T04:46:44+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Scala if else Statements &#8211; if, if-else if-else, Nested if-else Statements","datePublished":"2018-03-24T09:46:14+00:00","dateModified":"2021-12-04T04:46:44+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/"},"wordCount":486,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.jpg","keywords":["if else if statement scala","Scala Decision Making","scala if","scala if else alternative"],"articleSection":["Scala Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/","url":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/","name":"Scala if else Statements - if, if-else if-else, Nested if-else Statements - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.jpg","datePublished":"2018-03-24T09:46:14+00:00","dateModified":"2021-12-04T04:46:44+00:00","description":"Scala if else Statements,Scala if Statement,Scala if-else if-else Statement, Scala Nested if-else Statement, With examples and syntax, Scala Decision Making","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Scala-if-else-statement-01-1.jpg","width":1200,"height":628,"caption":"Scala if-else Statements with Example"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/scala-if-else-statements\/#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 if else Statements &#8211; if, if-else if-else, Nested if-else Statements"}]},{"@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\/11696","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=11696"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11696\/revisions"}],"predecessor-version":[{"id":104823,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11696\/revisions\/104823"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/31295"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=11696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=11696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=11696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}