Compare commits
2 Commits
63ba80b4a6
...
917649f35c
Author | SHA1 | Date |
---|---|---|
p1ng0ut | 917649f35c | |
p1ng0ut | ed6a2c39be |
|
@ -21,7 +21,7 @@ export PATH=<path_to_reval_md_bin_path>:$PATH
|
|||
or by adding this path to `~/.profile`. When this is done, you can execute the command:
|
||||
|
||||
```shell
|
||||
reveal-md docs/index.md
|
||||
reveal-md docs/index.md -w
|
||||
```
|
||||
|
||||
## Kotlin Native Build
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: Dezentrale Kotlin Course
|
||||
separator: <!--s-->
|
||||
verticalSeparator: <!--v-->
|
||||
separator: <!--next_chapter-->
|
||||
verticalSeparator: <!--next_slide-->
|
||||
theme: night
|
||||
revealOptions:
|
||||
transition: 'fade'
|
||||
|
@ -9,16 +9,16 @@ transition: 'fade'
|
|||
|
||||
# Kotlinkurs
|
||||
|
||||
<!--s-->
|
||||
<!--next_chapter-->
|
||||
|
||||
## Kotlin die Multiplattform-Sprache
|
||||
|
||||
- JVM: Java-Code kann in Kotlin eingebunden werden und umgekehrt
|
||||
- Android: Ausführung auf verschiedenen Geräten
|
||||
- JS: Client-Anwendungen lauffähig im Browser
|
||||
- Native: Kompilieren für jedes Betriebssystem (bspw. Windows, Linux, iOS und macOS)
|
||||
- **JVM**: Java-Code kann in Kotlin eingebunden werden und umgekehrt
|
||||
- **Android**: Ausführung auf verschiedenen Geräten
|
||||
- **JS**: Client-Anwendungen lauffähig im Browser
|
||||
- **Native**: Kompilieren für jedes Betriebssystem (bspw. Windows, Linux, iOS und macOS)
|
||||
|
||||
<!--v-->
|
||||
<!--next_slide-->
|
||||
|
||||
## Mehrere Programmierparadigmen möglich
|
||||
|
||||
|
@ -27,7 +27,7 @@ transition: 'fade'
|
|||
- _generische_ Programmierung,
|
||||
- _funktionale_ Programmierung und mehr.
|
||||
|
||||
<!--v-->
|
||||
<!--next_slide-->
|
||||
|
||||
## Etwas Geschichte
|
||||
|
||||
|
@ -36,7 +36,7 @@ transition: 'fade'
|
|||
- **2016** wurde Version 1.0 veröffentlicht
|
||||
- **2017** auf Google I/O erstklassiger Support angekündigt
|
||||
|
||||
<!--s-->
|
||||
<!--next_chapter-->
|
||||
|
||||
## Ein Beispielprogramm
|
||||
|
||||
|
@ -48,7 +48,7 @@ fun main() {
|
|||
}
|
||||
```
|
||||
|
||||
<!--v-->
|
||||
<!--next_slide-->
|
||||
|
||||
## Grundlegende Begriffe (1/2)
|
||||
|
||||
|
@ -56,7 +56,7 @@ fun main() {
|
|||
- Eine **Anweisung** ist ein einzelner auszuführender Befehl (drucke den Text),
|
||||
- Ein **Ausdruck** ist ein Codestück, das einen einzigen Wert ergibt (z. B. ist 2*2 ein Ausdruck)
|
||||
|
||||
<!--v-->
|
||||
<!--next_slide-->
|
||||
|
||||
## Grundlegende Begriffe (2/2)
|
||||
|
||||
|
@ -66,4 +66,35 @@ fun main() {
|
|||
- **Bezeichner** - Wort um etwas zu identifizieren
|
||||
- **Kommentare** - Text der beim Ausführen des Programms identifiziert wird
|
||||
|
||||
## Analyse Hello-World-Programm
|
||||
<!--next_slide-->
|
||||
|
||||
## Variablen deklarieren
|
||||
|
||||
- **val** (für value) deklariert unveränderliche Variable
|
||||
- **var** (für Variable) deklariert eine veränderbare Variable
|
||||
|
||||
Der anschließende, zwingend erforderliche Name darf nicht mit einer Zahl beginnen!
|
||||
|
||||
<!--next_slide-->
|
||||
|
||||
### Beispiel unveränderliche Variable:
|
||||
|
||||
```kotlin
|
||||
val language = "Kotlin"
|
||||
```
|
||||
|
||||
Achtung: Variablennamen sind case-sensitiv:
|
||||
|
||||
language != Language
|
||||
|
||||
<!--next_slide-->
|
||||
|
||||
### Beispiel veränderliche Variable:
|
||||
|
||||
```kotlin
|
||||
var dayOfWeek = "Monday"
|
||||
println(dayOfWeek) // prints Monday
|
||||
|
||||
dayOfWeek = "Tuesday"
|
||||
println(dayOfWeek) // prints Tuesday
|
||||
```
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
fun main() {
|
||||
println("Hello, Kotlin/Native!")
|
||||
// println(containsDuplicate(intArrayOf(1, 23, 34, 1)))
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package space.dezentrale.prgrnd
|
||||
fun containsDuplicate(nums: IntArray): Boolean {
|
||||
val unicates: MutableSet<Int> = mutableSetOf()
|
||||
nums.forEach {
|
||||
if (unicates.contains(it)) {
|
||||
return true
|
||||
} else {
|
||||
unicates.add(it)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package space.dezentrale.prgrnd
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ContainsDuplicateTest {
|
||||
@Test
|
||||
fun `it returns true for '1_2_3_1'`() {
|
||||
assertTrue(containsDuplicate(intArrayOf(1, 2, 3, 1)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `it returns false for '1_2_3_4'`() {
|
||||
assertFalse(containsDuplicate(intArrayOf(1, 2, 3, 4)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `it returns true for '1_1_1_3_3_4_3_2_4_2'`() {
|
||||
assertTrue(containsDuplicate(intArrayOf(1, 1, 1, 3, 3, 4, 3, 2, 4, 2)))
|
||||
}
|
||||
}
|
Reference in New Issue