

{"id":12604,"date":"2018-04-07T06:36:00","date_gmt":"2018-04-07T06:36:00","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=12604"},"modified":"2021-12-04T10:16:39","modified_gmt":"2021-12-04T04:46:39","slug":"scala-operator","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/scala-operator\/","title":{"rendered":"What is Scala Operator &#8211; 6 Major Types of Operators in Scala"},"content":{"rendered":"<p>In this Scala operator tutorial, we will disucss what is an operator in Scala. Moreover, we will discuss various types of Scala operators:\u00a0 Arithmetic, Relational, Logical, Bitwise, Assignment Operators in Scala with their syntax and examples.<\/p>\n<p>So, let&#8217;s start Scala Operator Tutorial.<\/p>\n<div id=\"attachment_12617\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-12617\" class=\"wp-image-12617 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01.jpg\" alt=\"What is Scala Operator - 6 Major Types of Operators in Scala\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-12617\" class=\"wp-caption-text\">What is Scala Operator &#8211; 6 Major Types of Operators in Scala<\/p><\/div>\n<h3>What are the Operators in Scala?<\/h3>\n<p>A symbol that instructs the compiler to perform certain mathematical or logical manipulations, is an operator.<\/p>\n<h3>Types of Scala Operators<\/h3>\n<p>We have the following types of Scala Operator:<\/p>\n<ul>\n<li>Arithmetic Operators<\/li>\n<li>Relational Operators<\/li>\n<li>Logical Operators<\/li>\n<li>Bitwise Operators<\/li>\n<li>Assignment Operators<\/li>\n<\/ul>\n<p>Let\u2019s discuss all Scala operator one by one.<\/p>\n<h4>a. Arithmetic Operators in Scala<\/h4>\n<p>This Scala operator tells Scala to perform arithmetic operations on two values. We have five of these. Let\u2019s take two values for exemplary purposes. (We did this in the Command Prompt).<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; val a=2\r\na: Int = 2\r\nscala&gt; val b=3\r\nb: Int = 3<\/pre>\n<h5>i. Addition (+)<\/h5>\n<p>This adds two operands. See an example.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a+b\r\nres0: Int = 5<\/pre>\n<h5>ii. Subtraction (-)<\/h5>\n<p>This subtracts the second operand from the first.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a-b\r\nres1: Int = -1<\/pre>\n<h5>iii. Multiplication (*)<\/h5>\n<p>This multiplies the two operands.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a*b\r\nres2: Int = 6<\/pre>\n<h5>iv. Division (\/)<\/h5>\n<p>This divides the first value by the second.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a\/b\r\nres3: Int = 0\r\nscala&gt; b\/a\r\nres4: Int = 1<\/pre>\n<h5>v. Modulus (%)<\/h5>\n<p>This returns the remainder after dividing the first number by the second.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a%b\r\nres6: Int = 2\r\nscala&gt; b%a\r\nres5: Int = 1<\/pre>\n<h4>b. Relational Operators in Scala<\/h4>\n<p>Now, let\u2019s discuss the Scala operator that let us compare values. They are rational Scala Operator.<\/p>\n<h5>i. Equal to (==)<\/h5>\n<p>This returns true if the two values are equal; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a==b\r\nres7: Boolean = false\r\nscala&gt; println(a==b)\r\nfalse<\/pre>\n<h5>ii. Not Equal to (!=)<\/h5>\n<p>This returns true if the two values are unequal; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a!=b\r\nres9: Boolean = true<\/pre>\n<h5>iii. Greater Than (&gt;)<\/h5>\n<p>This returns true if the first operand is greater than the second; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&gt;b\r\nres10: Boolean = false<\/pre>\n<h5>iv. Less Than (&lt;)<\/h5>\n<p>This returns true if the first operand is lesser than the second; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&lt;b\r\nres11: Boolean = true<\/pre>\n<h5>v. Greater Than or Equal to (&gt;=)<\/h5>\n<p>This returns true if the first operand is greater than or equal to the second; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&gt;=b\r\nres12: Boolean = false<\/pre>\n<h5>vi. Less Than or Equal to (&lt;=)<\/h5>\n<p>This returns true if the first operand is less than or equal to the second; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&lt;=b\r\nres13: Boolean = true<\/pre>\n<h4>c. Logical Operators in Scala<\/h4>\n<p>Moving on to logical Scala operator, we have three. Let\u2019s take Boolean values for this.<\/p>\n<h5>i. Logical AND (&amp;&amp;)<\/h5>\n<p>This returns true if both operands are true; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; true&amp;&amp;true\r\nres22: Boolean = true\r\nscala&gt; true&amp;&amp;false\r\nres23: Boolean = false<\/pre>\n<h5>ii. Logical OR (||)<\/h5>\n<p>This returns true if either or both operands are true; otherwise, false.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; true||false\r\nres25: Boolean = true\r\nscala&gt; false||false\r\nres26: Boolean = false<\/pre>\n<h5>iii. Logical NOT (!)<\/h5>\n<p>This reverses the operand\u2019s logical state. It turns true to false, and false to true.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; !true\r\nres27: Boolean = false\r\nscala&gt; !false\r\nres28: Boolean = true\r\nscala&gt; !(true&amp;&amp;false)\r\nres29: Boolean = true<\/pre>\n<h4>d. Bitwise Operators in Scala<\/h4>\n<p>Coming to Bitwise Scala operator, we have seven in Scala. But first, let\u2019s see the truth table for these:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>p<\/b><\/td>\n<td><b>q<\/b><\/td>\n<td><b>p&amp;q<\/b><\/td>\n<td><b>p|q<\/b><\/td>\n<td><b>p^q<\/b><\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Let\u2019s take two values:<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; var a=60 \/\/Its binary is 00111100\r\na: Int = 60\r\nscala&gt; var b=13 \/\/Its binary is 00001101\r\nb: Int = 13<\/pre>\n<h5>i. Binary AND Operator (&amp;)<\/h5>\n<p>This performs an AND operation on each pair of bits in the binary equivalents for the two operands.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&amp;b\r\nres43: Int = 12\r\n<\/pre>\n<p>This gives us 12 because of 00001100.<\/p>\n<h5>ii. Binary OR Operator (|)<\/h5>\n<p>This performs an OR operation on each pair of bits in the binary equivalents for the two operands.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a|b\r\nres44: Int = 61<\/pre>\n<p>The result is 61 because of 00111101.<\/p>\n<h5>iii. Binary XOR Operator (^)<\/h5>\n<p>This Scala Operator performs an XOR operation on each pair of bits in the binary equivalents for the two operands.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a^b\r\nres45: Int = 49<\/pre>\n<p>49 is decimal for 00110001.<\/p>\n<h5>iv. Binary One\u2019s Complement (~)<\/h5>\n<p>This flips the bits in the operand\u2019s binary equivalent.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; ~a \/\/This will be 11000011\r\nres46: Int = -61\r\nscala&gt; ~b\r\nres47: Int = -14<\/pre>\n<h5>v. Binary Left-Shift Operator (&lt;&lt;)<\/h5>\n<p>This Scala operator moves the bits of the left operand by (the right operand) number of bits to the left.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&lt;&lt;2\r\nres48: Int = 240<\/pre>\n<p>This is because it turns 00111100 to 11110000.<\/p>\n<h5>vi. Binary Right-Shift Operator (&gt;&gt;)<\/h5>\n<p>This Scala Operator moves the bits of the left operand by (the right operand) number of bits to the right.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&gt;&gt;2\r\nres49: Int = 15<\/pre>\n<p>This is because it turns 00111100 to 1111.<\/p>\n<h5>vii. Shift Right Zero Fill Operator (&gt;&gt;&gt;)<\/h5>\n<p>Shift Right Zero Fill Scala Operator moves the bits of the left operand by (the right operand) number of bits to the right, and fills these places with zeroes.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&gt;&gt;&gt;2\r\nres50: Int = 15<\/pre>\n<p>This turns 00111100 to 00001111.<\/p>\n<h4>e. Assignment Operators in Scala<\/h4>\n<p>Scala supports 11 different assignment operators:<\/p>\n<h5>i. Simple Assignment Operator (=)<\/h5>\n<p>This assigns the value on the right to the operand on the left.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; var a=1+2\r\na: Int = 3<\/pre>\n<h5>ii. Add and Assignment Operator (+=)<\/h5>\n<p>This Scala Operator adds the value of the right operand to the one on the left, and then assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a+=2 \/\/This is the same as a=a+2\r\nscala&gt; a\r\nres31: Int = 5<\/pre>\n<h5>iii. Subtract and Assignment Operator (-=)<\/h5>\n<p>This Scala operator subtracts the second operand from the first, then assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a-=3\r\nscala&gt; a\r\nres33: Int = 2<\/pre>\n<h5>iv. Multiply and Assignment Operator (*=)<\/h5>\n<p>This Scala Operator multiplies the two operands, and then assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt;\u00a0a*=7\r\nscala&gt; a\r\nres38: Int = 14<\/pre>\n<h5>v. Divide and Assignment Operator (\/=)<\/h5>\n<p>Divide And Assignment Scala Operator divides the first operand by the second, and then assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a\/=2\r\nscala&gt; a\r\nres40: Int = 7<\/pre>\n<h5>vi. Modulus and Assignment Operator (%=)<\/h5>\n<p>Modulus And Assignment Scala Operator calculates the modulus remaining after dividing the first operand by the second. Then, it assigns this result to the first operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a%=4\r\nscala&gt; a\r\nres42: Int = 3<\/pre>\n<h5>vii. Left-Shift and Assignment Operator (&lt;&lt;=)<\/h5>\n<p>This Scala operator shifts the left operand by (the right operand) number of bits to the left. Then, it assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&lt;&lt;=2\r\nscala&gt; a\r\nres57: Int = 240<\/pre>\n<p>We\u2019ll reset a to 60 every time so we can properly demonstrate the operators.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a=60\r\na: Int = 60<\/pre>\n<h5>viii. Right-Shift and Assignment Operator (&gt;&gt;=)<\/h5>\n<p>This Scala Operator shifts the left operand by (the right operand) number of bits to the right. Then, it assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&gt;&gt;=2\r\nscala&gt; a\r\nres59: Int = 15\r\nscala&gt; a=60\r\na: Int = 60<\/pre>\n<h5>ix. Bitwise AND Assignment Operator (&amp;=)<\/h5>\n<p>This applies the bitwise AND operator on the two operands, and then assigns the result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a&amp;=b\r\nscala&gt; a\r\nres61: Int = 12\r\nscala&gt; a=60\r\na: Int = 60<\/pre>\n<h5>x. Bitwise Exclusive-OR and Assignment Operator (^=)<\/h5>\n<p>This performs a bitwise XOR operation on the two operands, and then assigns this result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a^=b\r\nscala&gt; a\r\nres63: Int = 49\r\nscala&gt; a=60\r\na: Int = 60<\/pre>\n<h5>xi. Bitwise Inclusive-OR and Assignment Operator (|=)<\/h5>\n<p>This performs a bitwise-inclusive-OR operation on the two operands, and then assigns this result to the left operand.<\/p>\n<pre class=\"EnlighterJSRAW\">scala&gt; a|=b\r\nscala&gt; a\r\nres65: Int = 61<\/pre>\n<h3>Scala Operator Precedence<\/h3>\n<p>When we use multiple terms in an expression, how does Scala group them? This is decided by Scala operator precedence; this is how an expression evaluates. Some Scala operators have a higher precedence than others:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Category<\/b><\/td>\n<td><b>Operator<\/b><\/td>\n<td><b>Associativity<\/b><\/td>\n<\/tr>\n<tr>\n<td>Postfix<\/td>\n<td>() []<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Unary<\/td>\n<td>! ~<\/td>\n<td>Right to Left<\/td>\n<\/tr>\n<tr>\n<td>Multiplicative<\/td>\n<td>* \/ %<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Additive<\/td>\n<td>+ &#8211;<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Shift<\/td>\n<td>&gt;&gt; &gt;&gt;&gt; &lt;&lt;<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Relational<\/td>\n<td>&gt; &gt;= &lt; &lt;=<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Equality<\/td>\n<td>== !=<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Bitwise AND<\/td>\n<td>&amp;<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Bitwise XOR<\/td>\n<td>^<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Bitwise OR<\/td>\n<td>|<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Logical AND<\/td>\n<td>&amp;&amp;<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Logical OR<\/td>\n<td>||<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>Assignment<\/td>\n<td>= += -= *= \/= %= &gt;&gt;= &lt;&lt;= &amp;= ^= |=<\/td>\n<td>Right to Left<\/td>\n<\/tr>\n<tr>\n<td>Comma<\/td>\n<td>,<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In the table, the precedence decreases from top to bottom. Hence, the topmost operators have the highest precedencies. In an expression, the operators with a higher precedence evaluate first.<\/p>\n<p>For example, in val x=7+7*7, what evaluates first is 7*7, because * has a higher precedence than +. Then, 7+49 gives us 56.<\/p>\n<p>So, this was all about Scala Operator. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>Hence, we discussed types of Scala operators:\u00a0Arithmetic, Relational, Logical, Bitwise, Assignment Operators in Scala with their subtypes and examples.\u00a0Tell us what you think in the comments section.<\/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;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-29 09:04:33&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this Scala operator tutorial, we will disucss what is an operator in Scala. Moreover, we will discuss various types of Scala operators:\u00a0 Arithmetic, Relational, Logical, Bitwise, Assignment Operators in Scala with their syntax&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":31231,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[1106,1193,2011,11500,12516],"class_list":["post-12604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scala","tag-arithmetic-operators","tag-assignment-operators","tag-bitwise-operators","tag-relational-operators","tag-scala-operators"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is Scala Operator - 6 Major Types of Operators in Scala - DataFlair<\/title>\n<meta name=\"description\" content=\"Scala Operator: types Operators in Scala - Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators and Assignment Operators\" \/>\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-operator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Scala Operator - 6 Major Types of Operators in Scala - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Scala Operator: types Operators in Scala - Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators and Assignment Operators\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/scala-operator\/\" \/>\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-07T06:36:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-04T04:46:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-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=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Scala Operator - 6 Major Types of Operators in Scala - DataFlair","description":"Scala Operator: types Operators in Scala - Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators and Assignment Operators","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-operator\/","og_locale":"en_US","og_type":"article","og_title":"What is Scala Operator - 6 Major Types of Operators in Scala - DataFlair","og_description":"Scala Operator: types Operators in Scala - Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators and Assignment Operators","og_url":"https:\/\/data-flair.training\/blogs\/scala-operator\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-04-07T06:36:00+00:00","article_modified_time":"2021-12-04T04:46:39+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"What is Scala Operator &#8211; 6 Major Types of Operators in Scala","datePublished":"2018-04-07T06:36:00+00:00","dateModified":"2021-12-04T04:46:39+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/"},"wordCount":1185,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-1.jpg","keywords":["Arithmetic Operators","Assignment Operators","Bitwise Operators","Relational Operators","Scala Operators"],"articleSection":["Scala Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/scala-operator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/","url":"https:\/\/data-flair.training\/blogs\/scala-operator\/","name":"What is Scala Operator - 6 Major Types of Operators in Scala - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-1.jpg","datePublished":"2018-04-07T06:36:00+00:00","dateModified":"2021-12-04T04:46:39+00:00","description":"Scala Operator: types Operators in Scala - Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators and Assignment Operators","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/scala-operator\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/Scala-Operators-01-1.jpg","width":1200,"height":628,"caption":"Scala Operator"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/scala-operator\/#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":"What is Scala Operator &#8211; 6 Major Types of Operators 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\/12604","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=12604"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12604\/revisions"}],"predecessor-version":[{"id":104811,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12604\/revisions\/104811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/31231"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=12604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=12604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=12604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}