equal
deleted
inserted
replaced
1 // Scala Lecture 1 |
1 // Scala Lecture 1 |
2 //================= |
2 //================= |
|
3 |
3 |
4 |
4 // Value assignments |
5 // Value assignments |
5 // (their names should be lower case) |
6 // (their names should be lower case) |
6 //==================================== |
7 //==================================== |
7 |
8 |
|
9 val x = 42 |
|
10 val y = 3 + 4 |
|
11 val z = x / y |
|
12 val x = 70 |
|
13 print(z) |
|
14 |
|
15 // (you cannot reassign values: z = 9 will give an error) |
8 //var z = 9 |
16 //var z = 9 |
9 //z = 10 |
17 //z = 10 |
10 |
|
11 val x = 42 |
|
12 val y = 3 + 4 |
|
13 val z = x / y |
|
14 val x = 70 |
|
15 |
|
16 // (you cannot reassign values: z = 9 will give an error) |
|
17 |
|
18 |
18 |
19 // Hello World |
19 // Hello World |
20 //============= |
20 //============= |
21 |
21 |
22 // an example of a stand-alone Scala file |
22 // an example of a stand-alone Scala file |
90 print(tst) |
90 print(tst) |
91 println(tst) |
91 println(tst) |
92 |
92 |
93 val lst = List(1,2,3,1) |
93 val lst = List(1,2,3,1) |
94 |
94 |
95 |
|
96 println(lst.toString) |
95 println(lst.toString) |
97 |
96 |
98 println(lst.mkString) |
97 println(lst.mkString) |
99 println(lst.mkString(",")) |
98 println(lst.mkString(",")) |
100 |
|
101 println(lst.mkString(", ")) |
|
102 |
99 |
103 // some methods take more than one argument |
100 // some methods take more than one argument |
104 |
101 |
105 println(lst.mkString("{", ",", "}")) |
102 println(lst.mkString("{", ",", "}")) |
106 |
103 |