mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-12 01:34:19 +02:00
Merge pull request #1179 from cmpitg/master
[scala/en] Consistent code format & some minor language corrections
This commit is contained in:
@@ -5,6 +5,7 @@ contributors:
|
|||||||
- ["George Petrov", "http://github.com/petrovg"]
|
- ["George Petrov", "http://github.com/petrovg"]
|
||||||
- ["Dominic Bou-Samra", "http://dbousamra.github.com"]
|
- ["Dominic Bou-Samra", "http://dbousamra.github.com"]
|
||||||
- ["Geoff Liu", "http://geoffliu.me"]
|
- ["Geoff Liu", "http://geoffliu.me"]
|
||||||
|
- ["Ha-Duong Nguyen", "http://reference-error.org"]
|
||||||
filename: learn.scala
|
filename: learn.scala
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -16,15 +17,16 @@ Scala - the scalable language
|
|||||||
Set yourself up:
|
Set yourself up:
|
||||||
|
|
||||||
1) Download Scala - http://www.scala-lang.org/downloads
|
1) Download Scala - http://www.scala-lang.org/downloads
|
||||||
2) unzip/untar in your favourite location and put the bin subdir on the path
|
2) Unzip/untar to your favourite location and put the bin subdir in your `PATH` environment variable
|
||||||
3) Start a scala REPL by typing scala. You should see the prompt:
|
3) Start a Scala REPL by running `scala`. You should see the prompt:
|
||||||
|
|
||||||
scala>
|
scala>
|
||||||
|
|
||||||
This is the so called REPL (Read-Eval-Print Loop). You may type any valid
|
This is the so called REPL (Read-Eval-Print Loop). You may type any Scala
|
||||||
Scala expression into it, and the result will be printed. We will explain what
|
expression, and the result will be printed. We will explain what Scala files
|
||||||
Scala files look like further into this tutorial, but for now, let's start
|
look like further into this tutorial, but for now, let's start with some
|
||||||
with some basics.
|
basics.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -32,10 +34,10 @@ Scala - the scalable language
|
|||||||
// 1. Basics
|
// 1. Basics
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
// Single line comments start with two forward slashes
|
// Single-line comments start with two forward slashes
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Multi line comments, as you can already see from above, look like this.
|
Multi-line comments, as you can already see from above, look like this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Printing, and forcing a new line on the next print
|
// Printing, and forcing a new line on the next print
|
||||||
@@ -46,7 +48,7 @@ println(10)
|
|||||||
print("Hello world")
|
print("Hello world")
|
||||||
|
|
||||||
// Declaring values is done using either var or val.
|
// Declaring values is done using either var or val.
|
||||||
// val declarations are immutable, whereas var's are mutable. Immutability is
|
// val declarations are immutable, whereas vars are mutable. Immutability is
|
||||||
// a good thing.
|
// a good thing.
|
||||||
val x = 10 // x is now 10
|
val x = 10 // x is now 10
|
||||||
x = 20 // error: reassignment to val
|
x = 20 // error: reassignment to val
|
||||||
@@ -239,7 +241,7 @@ i // Show the value of i. Note that while is a loop in the classical sense -
|
|||||||
|
|
||||||
// A do while loop
|
// A do while loop
|
||||||
do {
|
do {
|
||||||
println("x is still less than 10");
|
println("x is still less than 10")
|
||||||
x += 1
|
x += 1
|
||||||
} while (x < 10)
|
} while (x < 10)
|
||||||
|
|
||||||
@@ -629,13 +631,8 @@ writer.close()
|
|||||||
|
|
||||||
## Further resources
|
## Further resources
|
||||||
|
|
||||||
[Scala for the impatient](http://horstmann.com/scala/)
|
* [Scala for the impatient](http://horstmann.com/scala/)
|
||||||
|
* [Twitter Scala school](http://twitter.github.io/scala_school/)
|
||||||
[Twitter Scala school](http://twitter.github.io/scala_school/)
|
* [The scala documentation](http://docs.scala-lang.org/)
|
||||||
|
* [Try Scala in your browser](http://scalatutorials.com/tour/)
|
||||||
[The scala documentation](http://docs.scala-lang.org/)
|
* Join the [Scala user group](https://groups.google.com/forum/#!forum/scala-user)
|
||||||
|
|
||||||
[Try Scala in your browser](http://scalatutorials.com/tour/)
|
|
||||||
|
|
||||||
Join the [Scala user group](https://groups.google.com/forum/#!forum/scala-user)
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user