@@ -15,38 +15,44 @@ next-page: scaladoc
15
15
16
16
Class/Object/Trait constructors should be declared all on one line,
17
17
unless the line becomes "too long" (about 100 characters). In that case,
18
- put each constructor argument on its own line, indented ** four** spaces:
18
+ put each constructor argument on its own line with
19
+ [ trailing commas] ( https://docs.scala-lang.org/sips/completed/trailing-commas.html#motivation ) :
19
20
20
21
class Person(name: String, age: Int) {
22
+ …
21
23
}
22
24
23
25
class Person(
24
- name: String,
25
- age: Int,
26
- birthdate: Date,
27
- astrologicalSign: String,
28
- shoeSize: Int,
29
- favoriteColor: java.awt.Color) {
30
- def firstMethod: Foo = ...
26
+ name: String,
27
+ age: Int,
28
+ birthdate: Date,
29
+ astrologicalSign: String,
30
+ shoeSize: Int,
31
+ favoriteColor: java.awt.Color,
32
+ ) {
33
+ def firstMethod: Foo = …
31
34
}
32
35
33
36
If a class/object/trait extends anything, the same general rule applies,
34
37
put it on one line unless it goes over about 100 characters, and then
35
- indent ** four** spaces with each item being on its own line and ** two**
36
- spaces for extensions; this provides visual separation between
37
- constructor arguments and extensions:
38
+ put each item on its own line with
39
+ [ trailing commas] ( https://docs.scala-lang.org/sips/completed/trailing-commas.html#motivation ) ;
40
+ closing parenthesis provides visual separation between constructor arguments and extensions;
41
+ empty line should be added to further separate extensions from class implementation:
38
42
39
43
class Person(
40
- name: String,
41
- age: Int,
42
- birthdate: Date,
43
- astrologicalSign: String,
44
- shoeSize: Int,
45
- favoriteColor: java.awt.Color)
46
- extends Entity
44
+ name: String,
45
+ age: Int,
46
+ birthdate: Date,
47
+ astrologicalSign: String,
48
+ shoeSize: Int,
49
+ favoriteColor: java.awt.Color,
50
+ ) extends Entity
47
51
with Logging
48
52
with Identifiable
49
53
with Serializable {
54
+
55
+ def firstMethod: Foo = …
50
56
}
51
57
52
58
### Ordering Of Class Elements
0 commit comments