{"id":534,"date":"2011-09-26T08:19:00","date_gmt":"2011-09-26T08:19:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/scala-tutorial-scala-repl-expressions-variables-basic-types-simple-functions-saving-and-running-programs-comments.html"},"modified":"2012-10-21T20:11:29","modified_gmt":"2012-10-21T20:11:29","slug":"scala-tutorial-scala-repl-expressions","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html","title":{"rendered":"Scala Tutorial &#8211; Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">\n<h2>              Preface<\/h2>\n<p>The is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate <a href=\"http:\/\/icl-f11.utcompling.com\/\">Introduction to Computational Linguistics course<\/a> at UT Austin, loosely based on similar tutorials that <a href=\"http:\/\/www.katrinerk.com\/\">Katrin Erk<\/a> created for <a href=\"http:\/\/comp.ling.utexas.edu\/courses\/2010\/fall\/introduction_to_computational_linguistics\">teaching Python in a similar course<\/a>. These tutorials assume no previous programming background, an assumption which is unfortunately still quite rare in the help-folks-learn-Scala universe, and which more or less necessitates the creation of these tutorials. The one exception I\u2019m aware of is <a href=\"http:\/\/www.simplyscala.com\/\">SimplyScala<\/a>.<\/p>\n<p><strong>Note<\/strong>: if you already know a programming language, this tutorial will probably not be very useful for you. (Though perhaps some of the later ones on functional programming and such that I intend to do will be, so check back.) In the meantime, check out existing Scala learning materials I\u2019ve listed in <a href=\"http:\/\/icl-f11.utcompling.com\/links\">the links page for the course.<\/a><\/p>\n<p>This tutorial assumes you have Scala installed and that you are using some form of Unix (if you use Windows, you\u2019ll want to look into Cygwin). If you are having problems with this, you might try the examples by evaluating them in the code box on SimplyScala.<\/p>\n<h2>              A (partial) starter tour of Scala expressions, variables, and basic types<\/h2>\n<p>We\u2019ll use the Scala REPL for entering Scala expressions and seeing what the result of evaluating them is. REPL stands for read-eval(uate)-print-loop, which means it is a program that (1) reads the expressions you type in, (2) evaluates them using the Scala compiler, (3) prints out the result of the evaluation, and then (4) waits for you to enter further expressions.<\/p>\n<p><strong>Note<\/strong>: it is very important that you actually type the commands given below into the REPL. If you just read them over, it will in many cases look quite obvious (and it is), but someone who is new to programming will generally find many gaps in their understanding by actually trying things out. In particular, programming languages are very exact, so they\u2019ll do exactly what you tell them to do \u2014 and you\u2019ll almost surely mess a few things up, and learn from that.<\/p>\n<p>In a Unix shell, type:<\/p>\n<pre class=\"brush: bash;\">$ scala\r\n<\/pre>\n<p>You should see something like the following:<\/p>\n<pre class=\"brush: bash;\">Welcome to Scala version 2.9.0.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).\r\nType in expressions to have them evaluated.\r\nType :help for more information.\r\n \r\nscala&gt;\r\n<\/pre>\n<p>The <strong>scala&gt;<\/strong> line is the prompt that the REPL is waiting for you to enter expressions. Let\u2019s enter some.<\/p>\n<pre class=\"brush: scala;\">scala&gt; \"Hello world\"\r\nres0: java.lang.String = Hello world\r\n \r\nscala&gt; 2\r\nres1: Int = 2\r\n<\/pre>\n<p>The REPL tells us that the first is a <em>String<\/em> which contains the characters <em>Hello world<\/em>, that the second is an <em>Int<\/em> whose value is the integer <em>2<\/em>. Strings and Ints are <strong>types<\/strong> \u2014 this is an easy but important distinction that sometimes takes beginning programmers a while to get used to. This allows Scala to know what to do when you want to use the <strong>numerical value<\/strong> 2 (an Int) or the <strong>character<\/strong> representing 2 (a String). For example, here is the latter.<\/p>\n<pre class=\"brush: scala;\">scala&gt; \"2\"\r\nres3: java.lang.String = 2\r\n<\/pre>\n<p>Scala knows that different actions are afforded by different types. For example, Ints can be added to each other.<\/p>\n<pre class=\"brush: scala;\">scala&gt; 2+3\r\nres4: Int = 5\r\n<\/pre>\n<p>Scala evaluates the result and prints the result to the screen. No surprise, the result is what you think it should be. With Strings, addition doesn\u2019t make sense, but the + operator instead indicates concatenation of the strings.<\/p>\n<pre class=\"brush: scala;\">scala&gt; \"Portis\" + \"head\"\r\nres5: java.lang.String = Portishead\r\n<\/pre>\n<p>So, if you consider the String \u201c2? and the String \u201c3?, and use the + operator on them, you don\u2019t get \u201c5? \u2014 instead you get \u201c23?.<\/p>\n<pre class=\"brush: scala;\">scala&gt; \"2\" + \"3\"\r\nres6: java.lang.String = 23\r\n<\/pre>\n<p>We can ask Scala to display the result of evaluating a given expression by using the <strong>print<\/strong> command.<\/p>\n<pre class=\"brush: scala;\">scala&gt; print (\"Hello world\")\r\nHello world\r\nscala&gt; print (2)\r\n2\r\nscala&gt; print (2 + 3)\r\n5\r\n<\/pre>\n<p>Note that the result is the action of printing, not a value with a type. For the last item, what happens is:<\/p>\n<ol>\n<li>Scala evaluates 2 + 3, which is 5.<\/li>\n<li>Scala passes that value to the command <strong>print<\/strong>.<\/li>\n<li><strong>print<\/strong> outputs \u201c5?<\/li>\n<\/ol>\n<p>You can think of the <strong>print<\/strong> command as a verb, and its parameter (e.g. <em>Hello world<\/em> or <em>2<\/em>) as its object.<\/p>\n<p>We often need to store the result of evaluating an expression to a variable for later use (in fact, programming doesn\u2019t get done with out doing this). Let\u2019s do this trivially to start with, breaking down the print statement above into two steps.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val x = 2 + 3\r\nx: Int = 5\r\n \r\nscala&gt; print (x)\r\n5\r\n<\/pre>\n<p>Here, <em>x<\/em> is a variable, which we\u2019ve indicate by prefacing it with <strong>val<\/strong>, which indicates it is a fixed variable whose value cannot change.<\/p>\n<p>You can choose the names for variables, but they must follow some rules.<\/p>\n<ul>\n<li>Variable names may contain: letters, numbers, underscore<\/li>\n<li>They must not start with a number<\/li>\n<li>They must not be identical to one of the \u201creserved words\u201d  that Scala has already defined, such as <strong>for<\/strong>, <strong>if<\/strong>, <strong>def<\/strong>, <strong>val<\/strong>, and <strong>var<\/strong><\/li>\n<\/ul>\n<p>Typical names for variables will be strings like <em>x<\/em>, <em>y1<\/em>, <em>result<\/em>, <em>firstName<\/em>, <em>here_is_a_long_variable_name<\/em>.<\/p>\n<p>Returning to the variable <em>x<\/em>, we can now use it for other computations.<\/p>\n<pre class=\"brush: scala;\">scala&gt; x + 3\r\nres12: Int = 8\r\n \r\nscala&gt; x * x\r\nres13: Int = 25\r\n<\/pre>\n<p>And of course, we can assign the results of such computations to other variables.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val y = 3 * x + 2\r\ny: Int = 17\r\n<\/pre>\n<p>Notice that Scala knows that multiplication takes precedence over addition in such computations. If we wanted to override that, we\u2019d need to use parentheses to indicate it, just like in basic algebra.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val z = 3 * (x + 2)\r\nz: Int = 21\r\n<\/pre>\n<p>Now, let\u2019s introduce another type, Double, for working with real-valued numbers. The Ints considered thus far are whole numbers, which do fine with multiplication, but will lead to behavior you might not expect when used with division.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush: scala;\">scala&gt; 5 * 2\r\nres12: Int = 10\r\n \r\nscala&gt; 7\/2\r\nres13: Int = 3\r\n<\/pre>\n<p>You probably expected to get 3.5 for the latter. However, because both 7 and 2 are Ints, Scala returns an Int \u2014 specifically it returns the number of times the denominator can go entirely into the numerator. To get the result you\u2019d normally want here, you need to use Doubles such as the following.<\/p>\n<pre class=\"brush: scala;\">scala&gt; 7.0\/2.0\r\nres14: Double = 3.5\r\n<\/pre>\n<p>Now the result is the value you\u2019d expect, and it is of type Double. Scala uses conventions to know the type of values, e.g. it knows that things in quotes are Strings, that numbers that have a \u201c.\u201d in them are Doubles, and that numbers without \u201c.\u201d are Ints. This is an important part of how it Scala <em>infers<\/em> the types of variables, which is a very useful and somewhat unique property among of languages of its kind (which are called <em>statically<\/em> typed languages). To see this in a bit more detail, note that you can tell Scala explicitly what a variable\u2019s type is.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val a: Int  = 2\r\na: Int = 2\r\n<\/pre>\n<p>The <strong>a: Int<\/strong> portion of the line indicates that the variable <em>a<\/em> has the type Int. Here are some examples of other variables with different types.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val b: Double = 3.14\r\nb: Double = 3.14\r\n \r\nscala&gt; val c: String = \"Hello world\"\r\nc: String = Hello world\r\n<\/pre>\n<p>Because Scala already knows these types, it is redundant to specify them in these cases. However, when expressions are more complicated, it is at times necessary to specify types explicitly.<\/p>\n<p>Importantly, we cannot assign the variable a type that conflicts with the result of the expression. Here, we try to assign a Double value to a variable of type Int, and Scala reports an error.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val d: Int = 6.28\r\n&lt;console&gt;:7: error: type mismatch;\r\nfound   : Double(6.28)\r\nrequired: Int\r\nval d: Int = 6.28\r\n^\r\n<\/pre>\n<p>In many cases, especially with beginning programming, you won\u2019t have to worry about declaring the types of your variables. We\u2019ll see situations where it is necessary as we progress.<\/p>\n<p>In addition to variables declared with <strong>val<\/strong>, Scala allows variables to be declared with <strong>var<\/strong> \u2014 these variable <em>can<\/em> have their values reassigned. A few examples are the easiest way to see the difference.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val a = 1\r\na: Int = 1\r\n \r\nscala&gt; a = 2\r\n&lt;console&gt;:8: error: reassignment to val\r\na = 2\r\n^\r\n \r\nscala&gt; var b = 5\r\nb: Int = 5\r\n \r\nscala&gt; b = 6\r\nb: Int = 6\r\n<\/pre>\n<p>You can think of a <strong>val<\/strong> variable as a sealed glass container into which you can look to see its value, but into which you cannot put anything new, and a <strong>var<\/strong> variable as an openable container that allows you both to see the value and to swap a new value in for the old one. We\u2019re going to focus on using vals mostly as they ultimately provide many advantages when combined with functional programming, and because I hope to get you thinking in terms of vals rather than vars while you are starting out.<\/p>\n<h2>              Functions<\/h2>\n<p>Variables are more useful when used in the context of functions in which a variable like <em>x<\/em> can be injected with different values by the user of a function. Let\u2019s consider converting degrees Fahrenheit to Celsius. To convert 87, 92, and 100 from Fahrenheit to Celcius, we could do the following.<\/p>\n<pre class=\"brush: scala;\">scala&gt; (87 - 32) * 5 \/ 9.0\r\nres15: Double = 30.555555555555557\r\n \r\nscala&gt; (92 - 32) * 5 \/ 9.0\r\nres16: Double = 33.333333333333336\r\n \r\nscala&gt; (100 - 32) * 5 \/ 9.0\r\nres17: Double = 37.77777777777778\r\n<\/pre>\n<p>Obviously, there is a lot of repetition here. Functions allow us to specify the common parts of such calculations, while allowing variables to specify the parts that may be different. In the conversion case, the only thing that changes is the temperature reading in Fahrenheit. Here\u2019s how we declare the appropriate function in Scala.<\/p>\n<pre class=\"brush: scala;\">scala&gt; def f2c (x: Double) = (x - 32) * 5\/9.0\r\nf2c: (x: Double)Double\r\n<\/pre>\n<p>Breaking this down we have:<\/p>\n<ul>\n<li><strong>def<\/strong> is a Scala keyword indicating that a function is being defined<\/li>\n<li><strong>f2c<\/strong> is the name given to the function<\/li>\n<li><strong>(x: Double)<\/strong> is the parameter to the function, which is a variable named <em>x<\/em> of type Double<\/li>\n<li><strong>(x \u2013 32) * 5\/9.0<\/strong> is the body of the function, which will take the value given by the user of the function, subtract 32 from it and then multiply the result of that by five-ninths<\/li>\n<\/ul>\n<p>Using the function is easy \u2014 give the name of the function, and then provide the value you are passing into the function in parentheses.<\/p>\n<pre class=\"brush: scala;\">scala&gt; f2c(87)\r\nres18: Double = 30.555555555555557\r\n \r\nscala&gt; f2c(92)\r\nres19: Double = 33.333333333333336\r\n \r\nscala&gt; f2c(100)\r\nres20: Double = 37.77777777777778\r\n<\/pre>\n<p>And so on. For each call, the function evaluates the expression for <em>x<\/em> equal  to the value passed into the function. Now we don\u2019t have to retype all the common stuff again and again.<\/p>\n<p>Functions can have multiple arguments. For example, the following is a function which takes two integers, squares each of them and then adds the squared values.<\/p>\n<pre class=\"brush: scala;\">scala&gt; def squareThenAdd (x: Int, y: Int) = x*x + y*y\r\nsquareThenAdd: (x: Int, y: Int)Int\r\n \r\nscala&gt; squareThenAdd(3,4)\r\nres21: Int = 25\r\n<\/pre>\n<p>Which indeed is the same as doing it explicitly.<\/p>\n<pre class=\"brush: scala;\">scala&gt; 3*3 + 4*4\r\nres22: Int = 25\r\n<\/pre>\n<p>An important aspect of functions is that all of the variables must be bound. If not, we get an error.<\/p>\n<pre class=\"brush: scala;\">scala&gt; def badFunctionWithUnboundVariable (x: Int) = x + y\r\n&lt;console&gt;:8: error: not found: value y\r\ndef badFunctionWithUnboundVariable (x: Int) = x + y\r\n<\/pre>\n<p>Functions can do much more complex and interesting things that what I\u2019ve shown here, which we\u2019ll get to in another tutorial.<\/p>\n<h2>              Editing programs in a text editor and running them on the command line<\/h2>\n<p>The REPL is very useful for trying out Scala expressions and seeing how they are evaluated in real time, but actual program development is done by writing a text file that contains a series of expressions that perform interesting behaviors. Doing this is straightforward. Open a text editor (see <a href=\"http:\/\/icl-f11.utcompling.com\/links\">the course links page<\/a> for some suggestions), and put the following as the first line, with nothing else.<\/p>\n<pre class=\"brush: scala;\">print (\"Hello world\")\r\n<\/pre>\n<p>Save this file as <strong>HelloWorld.scala<\/strong>, making sure it is saved as text only. Then in a Unix shell, go to the directory where that file is saved, and type the following.<\/p>\n<pre class=\"brush: bash;\">$ scala HelloWorld.scala\r\n<\/pre>\n<p>You\u2019ll see that <em>Hello world<\/em> is output, but that the Unix prompt is jammed up right after it. You may have expected it to print out and then leave the Unix prompt on the next line; however, there is nothing in the <strong>print<\/strong> command or in the string we asked it to print that indicates that a newline should have been used. To fix this, go back to the editor and change the line to be the following.<\/p>\n<pre class=\"brush: scala;\">print (\"Hello world\\n\")\r\n<\/pre>\n<p>When you run this, your Unix prompt appears on the line following <em>Hello world<\/em>. Characters like \u2018<strong>\\n<\/strong>\u2018 are metacharacters that indicate outputs other than standard characters like letters, numbers and symbols.<\/p>\n<p>Now, you could also have achieved the same result by writing.<\/p>\n<pre class=\"brush: scala;\">println (\"Hello world\")\r\n<\/pre>\n<p>The functions <strong>print<\/strong> and <strong>println<\/strong> are the same except that the latter always adds a newline at the end of its output \u2014 something that is often desired and thus simplifies the programmer\u2019s life. However, we still often need to use the newline character and other characters when outputting strings. For example, put the following into <strong>HelloWorld.scala<\/strong> and run it again.<\/p>\n<pre class=\"brush: scala;\">println(\"Hello world\\nHere is a list:\\n\\t1\\n\\t2\\n\\t3\")\r\n<\/pre>\n<p>From the output, it should be quite clear what \u2018<strong>\\t<\/strong>\u2018 means. Notice that it wasn\u2019t necessary to put \u2018<strong>\\n<\/strong>\u2018 after the final 3 because <strong>println<\/strong> was used instead of <strong>print<\/strong>.<\/p>\n<p>This is a trivial program, but in general they tend to get quite complex. This is where code comments come in handy. You can indicate that a line should be ignored by Scala as a comment by using two forward slashes. Comments can be used to indicate who the author of a program is, what the license is for it, documentation to help others (and your future self) understand what various parts of the code are doing, and commenting out lines of code that you don\u2019t want to erase but which you want temporarily inactive.<\/p>\n<p>Here\u2019s a slightly lengthier program with comments and function definitions and uses of those functions along with printing.<\/p>\n<pre class=\"brush: scala;\">\/\/ Author: Jason Baldridge (jasonbaldridge@gmail.com)\r\n \r\n\/\/ This is a trivial program for students learning to program with Scala.\r\n \r\n\/\/ This is a comment. The next line defines a function that squares\r\n\/\/ its argument.\r\ndef sq (x: Int) = x * x\r\n \r\n\/\/ The next line prints the result of calling sq with the argument 3.\r\nprintln(\"3 squared = \" + sq(3))\r\n \r\n\/\/ The next line is commented out, so even though it is a valid Scala\r\n\/\/ expression, it won't be evaluated by Scala.\r\n\/\/ println(\"4 squared = \" + sq(4))\r\n \r\n\/\/ Now, we define a function that uses the previously defined sq\r\n\/\/ (rather than using x*x and y*y as before).\r\ndef squareThenAdd (x: Int, y: Int) = sq(x) + sq(y)\r\n \r\n\/\/ Now we use it.\r\nprintln(\"Squaring 3 and 4 and adding the results = \"\r\n        + squareThenAdd(3,4))\r\n<\/pre>\n<p>Save this as <strong>ScalaFirstStepsPart1.scala<\/strong> and run it with the Scala executable. You should see the following results.<\/p>\n<pre class=\"brush: bash;\">$ scala ScalaFirstStepsPart1.scala\r\n3 squared = 9\r\nSquaring 3 and 4 and adding the results = 25\r\n<\/pre>\n<p>Looks good, right? But what is going on with those print statements? We saw earlier that 2+3 evaluates to 5, but that \u201c2?+\u201d3? evaluates to \u201c23?, and here we have used + on a String and an Int. Shouldn\u2019t that result in an error? What Scala is doing is converting the Int into a string automatically for us, which simplifies the outputing of results considerably. That means we can do things like the following (back to using the REPL).<\/p>\n<pre class=\"brush: scala;\">scala&gt; println(\"August \" + 22 + \", \" + 2011)\r\nAugust 22, 2011\r\n<\/pre>\n<p>That seems a bit pointless because we could have just written \u201cAugust 22, 2011?, but here\u2019s an example where it is a bit more useful: we can name tomorrow\u2019s day by using an Int for today\u2019s and adding one to it.<\/p>\n<pre class=\"brush: scala;\">scala&gt; val dayOfTheMonthToday = 22\r\ndayOfTheMonthToday: Int = 22\r\n \r\nscala&gt; println(\"Today is August \" + dayOfTheMonthToday + \" and tomorrow is August \" + (dayOfTheMonthToday+1))\r\nToday is August 22 and tomorrow is August 23\r\n<\/pre>\n<p>Note that the <strong>(dayOfTheMonthToday+1)<\/strong> part is actually Int addition, and the result of that is converted to a String that is concatenated with the rest of the string. This example is still fairly contrived (and obviously doesn\u2019t deal with the end of the month and all), but this autoconversion gets used a lot when you start working with more complex programs. And, perhaps even more obviously, we might reasonably want to add an Int and a Double.<\/p>\n<pre class=\"brush: scala;\">scala&gt; 2 + 3.0\r\nres27: Double = 5.0\r\n<\/pre>\n<p>Here, the result is a Double, since it is the more general type than Int. This kind of autoconversion happens a lot, and often you won\u2019t even realize it is going on.<\/p>\n<p>Another thing to note is that the last print statement went over multiple lines. We\u2019ll be seeing more about what the rules are for statements that run over multiple lines, but this example shows perhaps the easiest one to remember: when you open a parenthesis with \u201c(\u201c, you can keep on going multiple lines until its partner \u201c)\u201d is encountered. So, for example, we could have done the following very spread-out statement.<\/p>\n<pre class=\"brush: scala;\">println(\r\n  \"Squaring 3 and 4 and adding the results = \"\r\n \r\n  +\r\n \r\n  squareThenAdd(3,4)\r\n)\r\n<\/pre>\n<p>As well as being used for boxing in a bunch of code that is an argument to a function, as above, parentheses are quite useful for indicating the order of precedence of combining multiple items, such as indicating that an addition should be done before a multiplication, or that an Int addition should be done before a String concatenation, as shown earlier in the tutorial. Basically, parentheses are often optional, but if you can\u2019t remember what the default rules for expressions being grouped together are, then you can group them explicitly with parentheses.<\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/bcomposes.wordpress.com\/2011\/08\/22\/first-steps-in-scala-for-first-time-programmers-part-1\/\">First steps in Scala for first time programmers, Part 1<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Jason Baldridge at the <a href=\"http:\/\/bcomposes.wordpress.com\/\">Bcomposes<\/a> blog.<\/p>\n<p><strong><i>Related Articles :<\/i><\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-tuples-lists-methods-on.html\">Scala Tutorial &#8211; Tuples, Lists, methods on Lists and Strings<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-conditional-execution.html\">Scala Tutorial &#8211; conditional execution with if-else blocks and matching<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-iteration-for.html\">Scala Tutorial &#8211; iteration, for expressions, yield, map, filter, count<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-regular-expressions.html\">Scala Tutorial &#8211; regular expressions, matching<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-regular-expressions_05.html\">Scala Tutorial &#8211; regular expressions, matching and substitutions with the scala.util.matching API<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-maps-sets-groupby.html\">Scala Tutorial &#8211; Maps, Sets, groupBy, Options, flatten, flatMap<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-scalaiosource-accessing.html\">Scala Tutorial &#8211; scala.io.Source, accessing files, flatMap, mutable Maps<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-objects-classes.html\">Scala Tutorial &#8211; objects, classes, inheritance, traits, Lists with multiple related types, apply<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/scala-tutorial-scripting-compiling-main.html\">Scala Tutorial &#8211; scripting, compiling, main methods, return values of functions<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/11\/scala-tutorial-sbt-scalabha-packages.html\">Scala Tutorial &#8211; SBT, scalabha, packages, build systems<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/11\/scala-tutorial-code-blocks-coding-style.html\">Scala Tutorial &#8211; code blocks, coding style, closures, scala documentation project<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/fun-with-function-composition-in-scala.html\">Fun with function composition in Scala<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/how-scala-changed-way-i-think-about-my.html\">How Scala changed the way I think about my Java Code<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/what-features-of-java-have-been-dropped.html\">What features of Java have been dropped in Scala?<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/testing-with-scala.html\">Testing with Scala<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/things-every-programmer-should-know.html\">Things Every Programmer Should Know<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Preface The is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin, loosely based on similar tutorials that Katrin Erk created for teaching Python in a similar course. These tutorials assume no previous programming background, an assumption which is unfortunately still quite rare &hellip;<\/p>\n","protected":false},"author":67,"featured_media":227,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[235],"class_list":["post-534","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scala","tag-scala-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-26T08:19:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:11:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jason Baldridge\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/jasonbaldridge\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jason Baldridge\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html\"},\"author\":{\"name\":\"Jason Baldridge\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/95ef2670a4040b0f7101c48dba2795c0\"},\"headline\":\"Scala Tutorial &#8211; Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments\",\"datePublished\":\"2011-09-26T08:19:00+00:00\",\"dateModified\":\"2012-10-21T20:11:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html\"},\"wordCount\":2601,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/scala-logo.jpg\",\"keywords\":[\"Scala Tutorial\"],\"articleSection\":[\"Scala\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html\",\"name\":\"Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/scala-logo.jpg\",\"datePublished\":\"2011-09-26T08:19:00+00:00\",\"dateModified\":\"2012-10-21T20:11:29+00:00\",\"description\":\"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/scala-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/scala-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/scala-tutorial-scala-repl-expressions.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JVM Languages\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/jvm-languages\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Scala\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/jvm-languages\\\/scala\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Scala Tutorial &#8211; Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/95ef2670a4040b0f7101c48dba2795c0\",\"name\":\"Jason Baldridge\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g\",\"caption\":\"Jason Baldridge\"},\"sameAs\":[\"http:\\\/\\\/bcomposes.wordpress.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/pub\\\/jason-baldridge\\\/5\\\/629\\\/9b2\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/jasonbaldridge\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/jason-baldridge\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks","description":"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,","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:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html","og_locale":"en_US","og_type":"article","og_title":"Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks","og_description":"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,","og_url":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-09-26T08:19:00+00:00","article_modified_time":"2012-10-21T20:11:29+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg","type":"image\/jpeg"}],"author":"Jason Baldridge","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/jasonbaldridge","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jason Baldridge","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html"},"author":{"name":"Jason Baldridge","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/95ef2670a4040b0f7101c48dba2795c0"},"headline":"Scala Tutorial &#8211; Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments","datePublished":"2011-09-26T08:19:00+00:00","dateModified":"2012-10-21T20:11:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html"},"wordCount":2601,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg","keywords":["Scala Tutorial"],"articleSection":["Scala"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html","url":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html","name":"Scala Tutorial - Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg","datePublished":"2011-09-26T08:19:00+00:00","dateModified":"2012-10-21T20:11:29+00:00","description":"PrefaceThe is the first of several Scala tutorials I\u2019m creating for my Fall 2011 graduate Introduction to Computational Linguistics course at UT Austin,","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/scala-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/scala-tutorial-scala-repl-expressions.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JVM Languages","item":"https:\/\/www.javacodegeeks.com\/category\/jvm-languages"},{"@type":"ListItem","position":3,"name":"Scala","item":"https:\/\/www.javacodegeeks.com\/category\/jvm-languages\/scala"},{"@type":"ListItem","position":4,"name":"Scala Tutorial &#8211; Scala REPL, expressions, variables, basic types, simple functions, saving and running programs, comments"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/95ef2670a4040b0f7101c48dba2795c0","name":"Jason Baldridge","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b755d282f869512990e0ce9118c71ccd859fad42163f8e5d62d180ea42ea9720?s=96&d=mm&r=g","caption":"Jason Baldridge"},"sameAs":["http:\/\/bcomposes.wordpress.com\/","http:\/\/www.linkedin.com\/pub\/jason-baldridge\/5\/629\/9b2","https:\/\/x.com\/http:\/\/twitter.com\/jasonbaldridge"],"url":"https:\/\/www.javacodegeeks.com\/author\/jason-baldridge"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=534"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/534\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/227"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}