Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 36d3c33

Browse files
committed
Formatting
1 parent 59faf6c commit 36d3c33

File tree

19 files changed

+65
-60
lines changed

19 files changed

+65
-60
lines changed

src/i_introduction/_5_String_Templates/n05StringTemplates.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import util.TODO
44
import util.doc5
55

66
fun example1(a: Any, b: Any) =
7-
"This is some text in which variables ($a, $b) appear."
7+
"This is some text in which variables ($a, $b) appear."
88

99
fun example2(a: Any, b: Any) =
10-
"You can write it in a Java way as well. Like this: " + a + ", " + b + "!"
10+
"You can write it in a Java way as well. Like this: " + a + ", " + b + "!"
1111

1212
fun example3(c: Boolean, x: Int, y: Int) = "Any expression can be used: ${if (c) x else y}"
1313

1414
fun example4() =
15-
"""
15+
"""
1616
You can use raw strings to write multiline text.
1717
There is no escaping here, so raw strings are useful for writing regex patterns,
1818
you don't need to escape a backslash by a backslash.

src/i_introduction/_7_Nullable_Types/n07NullableTypes.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ fun todoTask7(client: Client?, message: String?, mailer: Mailer): Nothing = TODO
2323
)
2424

2525
fun sendMessageToClient(
26-
client: Client?, message: String?, mailer: Mailer
26+
client: Client?, message: String?, mailer: Mailer
2727
) {
2828
todoTask7(client, message, mailer)
2929
}
3030

31-
class Client (val personalInfo: PersonalInfo?)
32-
class PersonalInfo (val email: String?)
31+
class Client(val personalInfo: PersonalInfo?)
32+
class PersonalInfo(val email: String?)
3333

3434
interface Mailer {
3535
fun sendMessage(email: String, message: String)

src/i_introduction/_8_Smart_Casts/n08SmartCasts.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import util.doc8
66
// 'sealed' modifier restricts the type hierarchy:
77
// all the subclasses must be declared in the same file
88
sealed class Expr
9+
910
class Num(val value: Int) : Expr()
1011
class Sum(val left: Expr, val right: Expr) : Expr()
1112

1213
fun eval(e: Expr): Int =
13-
when (e) {
14-
is Num -> todoTask8(e)
15-
is Sum -> todoTask8(e)
16-
}
14+
when (e) {
15+
is Num -> todoTask8(e)
16+
is Sum -> todoTask8(e)
17+
}
1718

1819
fun todoTask8(expr: Expr): Nothing = TODO(
1920
"""

src/ii_collections/n16FlatMap.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ fun example() {
77
result == listOf('a', 'b', 'c', '1', '2')
88
}
99

10-
val Customer.orderedProducts: Set<Product> get() {
11-
// Return all products this customer has ordered
12-
todoCollectionTask()
13-
}
10+
val Customer.orderedProducts: Set<Product>
11+
get() {
12+
// Return all products this customer has ordered
13+
todoCollectionTask()
14+
}
1415

15-
val Shop.allOrderedProducts: Set<Product> get() {
16-
// Return all products that were ordered by at least one customer
17-
todoCollectionTask()
18-
}
16+
val Shop.allOrderedProducts: Set<Product>
17+
get() {
18+
// Return all products that were ordered by at least one customer
19+
todoCollectionTask()
20+
}

src/ii_collections/n22Fold.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ fun example9() {
88
// The same as
99
fun whatFoldDoes(): Int {
1010
var result = 1
11-
listOf(1, 2, 3, 4).forEach { element -> result = element * result}
11+
listOf(1, 2, 3, 4).forEach { element -> result = element * result }
1212
return result
1313
}
1414

1515
fun Shop.getSetOfProductsOrderedByEachCustomer(): Set<Product> {
1616
// Return the set of products that were ordered by each of the customers
17-
return customers.fold(allOrderedProducts, {
18-
orderedByAll, customer ->
17+
return customers.fold(allOrderedProducts, { orderedByAll, customer ->
1918
todoCollectionTask()
2019
})
2120
}

src/ii_collections/n24ExtensionsOnCollections.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fun todoTask24(): Nothing = TODO(
88
The function should do the same as '_24_JavaCode.doSomethingStrangeWithCollection'.
99
Replace all invocations of 'todoTask24()' with the appropriate code.
1010
""",
11-
references = { c: Collection<String> -> _24_JavaCode().doSomethingStrangeWithCollection(c) }
11+
references = { c: Collection<String> -> _24_JavaCode().doSomethingStrangeWithCollection(c) }
1212
)
1313

1414
fun doSomethingStrangeWithCollection(collection: Collection<String>): Collection<String>? {

src/ii_collections/todoUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package ii_collections
33
import util.TODO
44

55
fun todoCollectionTask(): Nothing = TODO(
6-
"""
6+
"""
77
Common task for working with collections.
88
Look through the Shop API, which all the tasks are using.
99
Each individual task is described in the function name and the comment.
1010
""",
11-
references = { shop: Shop -> shop.customers }
11+
references = { shop: Shop -> shop.customers }
1212
)

src/iii_conventions/MyDateUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package iii_conventions
22

3-
import iii_conventions.TimeInterval.*
3+
import iii_conventions.TimeInterval.DAY
44
import java.util.*
55

66
fun MyDate.nextDay() = addTimeIntervals(DAY, 1)

src/iii_conventions/n28ForLoop.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ import util.TODO
44
import util.doc28
55

66
fun iterateOverCollection(collection: Collection<Int>) {
7-
for (element in collection) {}
7+
for (element in collection) {
8+
}
89
}
910

1011
fun iterateOverString() {
1112
// You can iterate over anything that has an 'iterator' method, member or extension.
12-
for (c in "abcd") {}
13+
for (c in "abcd") {
14+
}
1315
"abcd".iterator() //library extension method
1416
}
1517

1618
fun iterateOverRange() {
17-
for (i in 1..10) {}
18-
for (c in 'a'..'z') {}
19+
for (i in 1..10) {
20+
}
21+
for (c in 'a'..'z') {
22+
}
1923
}
2024

2125
fun todoTask28(): Nothing = TODO(

src/iii_conventions/n29OperatorsOverloading.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package iii_conventions
22

3-
import util.TODO
43
import iii_conventions.TimeInterval.*
4+
import util.TODO
55

66
fun todoTask29(): Nothing = TODO(
77
"""

0 commit comments

Comments
 (0)