From f30200b31c60f082cf4f192245a4a2c058f76fa4 Mon Sep 17 00:00:00 2001 From: Kaleb Davis Date: Tue, 6 Oct 2015 21:22:09 -0400 Subject: Add examples to show how printing works --- scala.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scala.html.markdown') diff --git a/scala.html.markdown b/scala.html.markdown index c482752d..7189be10 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -43,9 +43,13 @@ Scala - the scalable language // Printing, and forcing a new line on the next print println("Hello world!") println(10) +// Hello world! +// 10 // Printing, without forcing a new line on next print print("Hello world") +print(10) +// Hello world!10 // Declaring values is done using either var or val. // val declarations are immutable, whereas vars are mutable. Immutability is -- cgit v1.2.3 From 7c2c4480600b6c817418d5ba04315bca3c5a400d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Costa?= Date: Sat, 10 Oct 2015 16:49:53 +0100 Subject: Fix compile errors of the English and French Scala tutorials --- scala.html.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scala.html.markdown') diff --git a/scala.html.markdown b/scala.html.markdown index 7189be10..7f545196 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -6,7 +6,6 @@ contributors: - ["Dominic Bou-Samra", "http://dbousamra.github.com"] - ["Geoff Liu", "http://geoffliu.me"] - ["Ha-Duong Nguyen", "http://reference-error.org"] -filename: learn.scala --- Scala - the scalable language @@ -244,10 +243,11 @@ i // Show the value of i. Note that while is a loop in the classical sense - // comprehensions above is easier to understand and parallelize // A do while loop +i = 0 do { - println("x is still less than 10") - x += 1 -} while (x < 10) + println("i is still less than 10") + i += 1 +} while (i < 10) // Tail recursion is an idiomatic way of doing recurring things in Scala. // Recursive functions need an explicit return type, the compiler can't infer it. @@ -566,8 +566,8 @@ sendGreetings("Jane") // => "Hello Jane, 100 blessings to you and yours!" // Implicit function parameters enable us to simulate type classes in other // functional languages. It is so often used that it gets its own shorthand. The // following two lines mean the same thing: -def foo[T](implicit c: C[T]) = ... -def foo[T : C] = ... +// def foo[T](implicit c: C[T]) = ... +// def foo[T : C] = ... // Another situation in which the compiler looks for an implicit is if you have -- cgit v1.2.3