summaryrefslogtreecommitdiffhomepage
path: root/scala.html.markdown
diff options
context:
space:
mode:
authorven <vendethiel@hotmail.fr>2016-01-25 11:28:08 +0100
committerven <vendethiel@hotmail.fr>2016-01-25 11:28:08 +0100
commit510f4e239e29f8a59bf9e50fe9fef4db30a44407 (patch)
tree2ee8e1bb63b16a2e28b3f61135d78839ba0f68ac /scala.html.markdown
parente4657408f45d7dc25fb856b3497378cfc8da6b41 (diff)
parentb336e810865a1a2ce54c53b467bcd1545455a679 (diff)
Merge pull request #1950 from pikazlou/scala-flow-control-fix
fix docs for Flow Control
Diffstat (limited to 'scala.html.markdown')
-rw-r--r--scala.html.markdown13
1 files changed, 7 insertions, 6 deletions
diff --git a/scala.html.markdown b/scala.html.markdown
index c2aa942c..e82c1c36 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -237,7 +237,7 @@ r foreach println
(5 to 1 by -1) foreach (println)
-// A while loops
+// A while loop
var i = 0
while (i < 10) { println("i " + i); i += 1 }
@@ -245,17 +245,18 @@ while (i < 10) { println("i " + i); i += 1 } // Yes, again. What happened? Why
i // Show the value of i. Note that while is a loop in the classical sense -
// it executes sequentially while changing the loop variable. while is very
- // fast, faster that Java loops, but using the combinators and
- // comprehensions above is easier to understand and parallelize
+ // fast, but using the combinators and comprehensions above is easier
+ // to understand and parallelize
-// A do while loop
+// A do-while loop
i = 0
do {
println("i is still less than 10")
i += 1
} while (i < 10)
-// Tail recursion is an idiomatic way of doing recurring things in Scala.
+// Recursion is the idiomatic way of repeating an action in Scala (as in most
+// other functional languages).
// Recursive functions need an explicit return type, the compiler can't infer it.
// Here it's Unit.
def showNumbersInRange(a: Int, b: Int): Unit = {
@@ -273,7 +274,7 @@ val x = 10
if (x == 1) println("yeah")
if (x == 10) println("yeah")
if (x == 11) println("yeah")
-if (x == 11) println ("yeah") else println("nay")
+if (x == 11) println("yeah") else println("nay")
println(if (x == 10) "yeah" else "nope")
val text = if (x == 10) "yeah" else "nope"