Skip to content

Commit 353b38f

Browse files
committed
Compile course
1 parent 62fc7e1 commit 353b38f

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

compiled_starters/kotlin/src/main/kotlin/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fun main(args: Array<String>) {
2020
// databaseFile.skip(16) // Skip the first 16 bytes of the header
2121
// val pageSizeBytes = ByteArray(2) // The following 2 bytes are the page size
2222
// databaseFile.read(pageSizeBytes)
23-
// val pageSize = java.nio.ByteBuffer.wrap(pageSizeBytes).short.toInt()
23+
// val pageSize = pageSizeBytes[0].toUByte() * 256u + pageSizeBytes[1].toUByte()
2424
// println("database page size: $pageSize")
2525

2626
databaseFile.close()

solutions/kotlin/01-dr6/code/src/main/kotlin/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fun main(args: Array<String>) {
1515
databaseFile.skip(16) // Skip the first 16 bytes of the header
1616
val pageSizeBytes = ByteArray(2) // The following 2 bytes are the page size
1717
databaseFile.read(pageSizeBytes)
18-
val pageSize = java.nio.ByteBuffer.wrap(pageSizeBytes).short.toInt()
18+
val pageSize = pageSizeBytes[0].toUByte() * 256u + pageSizeBytes[1].toUByte()
1919
println("database page size: $pageSize")
2020

2121
databaseFile.close()

solutions/kotlin/01-dr6/diff/src/main/kotlin/Main.kt.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
- // databaseFile.skip(16) // Skip the first 16 bytes of the header
2222
- // val pageSizeBytes = ByteArray(2) // The following 2 bytes are the page size
2323
- // databaseFile.read(pageSizeBytes)
24-
- // val pageSize = java.nio.ByteBuffer.wrap(pageSizeBytes).short.toInt()
24+
- // val pageSize = pageSizeBytes[0].toUByte() * 256u + pageSizeBytes[1].toUByte()
2525
- // println("database page size: $pageSize")
2626
+ databaseFile.skip(16) // Skip the first 16 bytes of the header
2727
+ val pageSizeBytes = ByteArray(2) // The following 2 bytes are the page size
2828
+ databaseFile.read(pageSizeBytes)
29-
+ val pageSize = java.nio.ByteBuffer.wrap(pageSizeBytes).short.toInt()
29+
+ val pageSize = pageSizeBytes[0].toUByte() * 256u + pageSizeBytes[1].toUByte()
3030
+ println("database page size: $pageSize")
3131

3232
databaseFile.close()

solutions/kotlin/01-dr6/explanation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Study and uncomment the relevant code:
88
databaseFile.skip(16) // Skip the first 16 bytes of the header
99
val pageSizeBytes = ByteArray(2) // The following 2 bytes are the page size
1010
databaseFile.read(pageSizeBytes)
11-
val pageSize = java.nio.ByteBuffer.wrap(pageSizeBytes).short.toInt()
11+
val pageSize = pageSizeBytes[0].toUByte() * 256u + pageSizeBytes[1].toUByte()
1212
println("database page size: $pageSize")
1313
```
1414

0 commit comments

Comments
 (0)