diff --git a/Advanced Topics/Erasure & Reification/Examples/src/ErasedTypeEquivalence.kt b/Advanced Topics/Erasure & Reification/Examples/src/ErasedTypeEquivalence.kt deleted file mode 100644 index 79d7aa83..00000000 --- a/Advanced Topics/Erasure & Reification/Examples/src/ErasedTypeEquivalence.kt +++ /dev/null @@ -1,8 +0,0 @@ -// Erasure/ErasedTypeEquivalence.kt -import atomictest.eq - -fun main() { - val c1 = listOf()::class - val c2 = listOf()::class - c1 eq c2 -} \ No newline at end of file diff --git a/Advanced Topics/Erasure & Reification/Examples/src/TypeOfT.kt b/Advanced Topics/Erasure & Reification/Examples/src/TypeOfT.kt deleted file mode 100644 index 60374097..00000000 --- a/Advanced Topics/Erasure & Reification/Examples/src/TypeOfT.kt +++ /dev/null @@ -1,22 +0,0 @@ -// Erasure/TypeOfT.kt -package generics -import atomictest.eq - -fun typeOfT(arg: T) = - "$arg: " + when(arg) { - is Car -> "Car" - is Int -> "Int" - is String -> "String" - else -> "${(arg?:"")::class}" -} - -data class Alien( - val n:String = "Pibbles") - -fun main() { - typeOfT(Car()) eq "Car(name=Car): Car" - typeOfT(1) eq "1: Int" - typeOfT("Morty") eq "Morty: String" - typeOfT(Alien()) eq - "Alien(n=Pibbles): class generics.Alien" -} \ No newline at end of file diff --git a/Advanced Topics/Erasure & Reification/Examples/task-info.yaml b/Advanced Topics/Erasure & Reification/Examples/task-info.yaml deleted file mode 100644 index 70601c65..00000000 --- a/Advanced Topics/Erasure & Reification/Examples/task-info.yaml +++ /dev/null @@ -1,6 +0,0 @@ -type: theory -files: -- name: src/ErasedTypeEquivalence.kt - visible: true -- name: src/TypeOfT.kt - visible: true diff --git a/Advanced Topics/Erasure & Reification/Examples/task.md b/Advanced Topics/Erasure & Reification/Examples/task.md deleted file mode 100644 index 961bfcad..00000000 --- a/Advanced Topics/Erasure & Reification/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Erasure & Reification - -Examples accompanying the atom. \ No newline at end of file diff --git a/Advanced Topics/Erasure & Reification/lesson-info.yaml b/Advanced Topics/Erasure & Reification/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Advanced Topics/Erasure & Reification/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Advanced Topics/Reflection/Examples/src/Info.kt b/Advanced Topics/Reflection/Examples/src/Info.kt deleted file mode 100644 index f5c1c90e..00000000 --- a/Advanced Topics/Reflection/Examples/src/Info.kt +++ /dev/null @@ -1,30 +0,0 @@ -// Reflection/Info.kt - -fun info(a: Any) { - val kc = a::class - println("${kc::class}") - kc::class.supertypes.forEach { - println("$it") - } - println("---") - kc::class.members.forEach { println("$it") } - println("===") - println("simpleName: ${kc.simpleName}") - println( - "qualifiedName: ${kc.qualifiedName}") - println("Constructors:") - kc.constructors.forEach { println("$it") } - println("Members:") - kc.members.forEach { println(" $it") } - println("Super Types:") - kc.supertypes.forEach { println(" $it") } - println("isData: ${kc.isData}") -} - -data class Baz(val i: Int, val s: String) { - constructor(): this(11, "Joy") -} - -fun main() { - info(Baz(1, "Happy")) -} \ No newline at end of file diff --git a/Advanced Topics/Reflection/Examples/src/Name.kt b/Advanced Topics/Reflection/Examples/src/Name.kt deleted file mode 100644 index 1ba08807..00000000 --- a/Advanced Topics/Reflection/Examples/src/Name.kt +++ /dev/null @@ -1,5 +0,0 @@ -// Reflection/Name.kt -package reflection - -fun className(a: Any): String = - a::class.simpleName ?: "" \ No newline at end of file diff --git a/Advanced Topics/Reflection/Examples/src/Solid.kt b/Advanced Topics/Reflection/Examples/src/Solid.kt deleted file mode 100644 index ca172011..00000000 --- a/Advanced Topics/Reflection/Examples/src/Solid.kt +++ /dev/null @@ -1,17 +0,0 @@ -// Reflection/Solid.kt -import atomictest.eq -import reflection.className - -class Solid { - override fun toString() = className(this) -} - -class Solid2(val size: Int) { - override fun toString() = - "${className(this)}($size)" -} - -fun main() { - Solid() eq "Solid" - Solid2(47) eq "Solid2(47)" -} \ No newline at end of file diff --git a/Advanced Topics/Reflection/Examples/task-info.yaml b/Advanced Topics/Reflection/Examples/task-info.yaml deleted file mode 100644 index e1da5f3e..00000000 --- a/Advanced Topics/Reflection/Examples/task-info.yaml +++ /dev/null @@ -1,8 +0,0 @@ -type: theory -files: -- name: src/Name.kt - visible: true -- name: src/Solid.kt - visible: true -- name: src/Info.kt - visible: true diff --git a/Advanced Topics/Reflection/Examples/task.md b/Advanced Topics/Reflection/Examples/task.md deleted file mode 100644 index b64f2912..00000000 --- a/Advanced Topics/Reflection/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Reflection - -Examples accompanying the atom. \ No newline at end of file diff --git a/Advanced Topics/Reflection/lesson-info.yaml b/Advanced Topics/Reflection/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Advanced Topics/Reflection/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Advanced Topics/Variance & Star Projections/Examples/src/Bird.kt b/Advanced Topics/Variance & Star Projections/Examples/src/Bird.kt deleted file mode 100644 index eb4f0791..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/src/Bird.kt +++ /dev/null @@ -1,22 +0,0 @@ -// Variance/Bird.kt -package variance -import atomictest.eq - -open class Bird -open class Duck: Bird() -class Mallard: Duck() - -open class MakeBird { - open fun make(): Bird = Bird() -} - -fun test(maker: MakeBird, result: String) { - val bird = maker.make() - val name = bird::class.simpleName ?: "" - name eq result -} - -fun main() { - test(MakeBird(), "Bird") - val b: Bird = MakeBird().make() -} \ No newline at end of file diff --git a/Advanced Topics/Variance & Star Projections/Examples/src/Contravariance.kt b/Advanced Topics/Variance & Star Projections/Examples/src/Contravariance.kt deleted file mode 100644 index 2ba50dc6..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/src/Contravariance.kt +++ /dev/null @@ -1,28 +0,0 @@ -// Variance/Contravariance.kt -package variance -import atomictest.eq - -open class Base { - open fun f(b: Mallard) = "Base::f" -} - -open class Derived: Base() { - /* override */ fun f(b: Duck) = - "Derived::f" -} - -class Derived2: Derived() { - /* override */ fun f(b: Bird) = - "Derived2::f" -} - -fun main() { - Derived2().f(Mallard()) eq "Base::f" - Derived2().f(Duck()) eq "Derived::f" - Derived2().f(Bird()) eq "Derived2::f" - - Derived().f(Mallard()) eq "Base::f" - Derived().f(Duck()) eq "Derived::f" - - Base().f(Mallard()) eq "Base::f" -} \ No newline at end of file diff --git a/Advanced Topics/Variance & Star Projections/Examples/src/CovariantReturnTypes.kt b/Advanced Topics/Variance & Star Projections/Examples/src/CovariantReturnTypes.kt deleted file mode 100644 index 29fec329..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/src/CovariantReturnTypes.kt +++ /dev/null @@ -1,29 +0,0 @@ -// Variance/CovariantReturnTypes.kt -package variance - -open class MakeDuck2: MakeBird() { - override fun make(): Duck = Duck() -} - -class MakeMallard2: MakeDuck2() { - override fun make(): Mallard = Mallard() -} - -class Bicycle - -class MakeBicycle: MakeBird() { - // Fails: - // override fun make(): Bicycle = Bicycle() - val errorMessage = """ - Return type of 'make' is not a subtype of - the return type of the overridden member - 'public open fun make(): Bird' - """ -} - -fun main() { - test(MakeDuck2(), "Duck") - test(MakeMallard2(), "Mallard") - val d: Duck = MakeDuck2().make() - val m: Mallard = MakeMallard2().make() -} \ No newline at end of file diff --git a/Advanced Topics/Variance & Star Projections/Examples/src/SameReturnTypes.kt b/Advanced Topics/Variance & Star Projections/Examples/src/SameReturnTypes.kt deleted file mode 100644 index 339e067e..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/src/SameReturnTypes.kt +++ /dev/null @@ -1,18 +0,0 @@ -// Variance/SameReturnTypes.kt -package variance - -open class MakeDuck1: MakeBird() { - override fun make(): Bird = Duck() -} - -class MakeMallard1: MakeDuck1() { - override fun make(): Bird = Mallard() -} - -fun main() { - test(MakeDuck1(), "Duck") - test(MakeMallard1(), "Mallard") - val d: Duck = MakeDuck1().make() as Duck - val m: Mallard = - MakeMallard1().make() as Mallard -} \ No newline at end of file diff --git a/Advanced Topics/Variance & Star Projections/Examples/task-info.yaml b/Advanced Topics/Variance & Star Projections/Examples/task-info.yaml deleted file mode 100644 index bbe040f4..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/task-info.yaml +++ /dev/null @@ -1,10 +0,0 @@ -type: theory -files: -- name: src/Bird.kt - visible: true -- name: src/SameReturnTypes.kt - visible: true -- name: src/CovariantReturnTypes.kt - visible: true -- name: src/Contravariance.kt - visible: true diff --git a/Advanced Topics/Variance & Star Projections/Examples/task.md b/Advanced Topics/Variance & Star Projections/Examples/task.md deleted file mode 100644 index d21db695..00000000 --- a/Advanced Topics/Variance & Star Projections/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Variance & Star Projections - -Examples accompanying the atom. \ No newline at end of file diff --git a/Advanced Topics/Variance & Star Projections/lesson-info.yaml b/Advanced Topics/Variance & Star Projections/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Advanced Topics/Variance & Star Projections/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Advanced Topics/section-info.yaml b/Advanced Topics/section-info.yaml deleted file mode 100644 index 7a87b167..00000000 --- a/Advanced Topics/section-info.yaml +++ /dev/null @@ -1,4 +0,0 @@ -content: -- Variance & Star Projections -- Erasure & Reification -- Reflection diff --git a/Concurrency/Coroutines/Examples/src/CompareDelayingTask.kt b/Concurrency/Coroutines/Examples/src/CompareDelayingTask.kt deleted file mode 100644 index 4bd01741..00000000 --- a/Concurrency/Coroutines/Examples/src/CompareDelayingTask.kt +++ /dev/null @@ -1,41 +0,0 @@ -// Coroutines/CompareDelayingTask.kt -import atomictest.eq -import kotlinx.coroutines.* -import kotlin.system.measureTimeMillis - -suspend fun task(): Int { - delay(1000L) // Performing work... - return 111 // Result of work -} - -fun sequentialTasks() = runBlocking { - measureTimeMillis { - val result = - List(5) { task() }.sumBy { it } - result eq 555 - }.toDouble() -} - -fun parallelTasks() = runBlocking { - measureTimeMillis { - val result = - List(5) { async { task() } } - .sumBy { it.await() } - result eq 555 - }.toDouble() -} - -// Simple round to two decimal places: -fun round2dp(d: Double) = - Math.round(d * 100) / 100.0 - -fun main() { - val seq = sequentialTasks() - val par = parallelTasks() - println("Ratio: ${round2dp(seq / par)}") -} -/* Sample output: -555 -555 -Ratio: 4.88 -*/ \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/CompareSlowFib.kt b/Concurrency/Coroutines/Examples/src/CompareSlowFib.kt deleted file mode 100644 index fc32bdd0..00000000 --- a/Concurrency/Coroutines/Examples/src/CompareSlowFib.kt +++ /dev/null @@ -1,53 +0,0 @@ -// Coroutines/CompareSlowFib.kt -import bigint.* -import kotlinx.coroutines.* -import kotlin.system.measureTimeMillis - -// Slow Fibonacci function: -fun fibs(n: BigInt): BigInt { - assert(n >= zero) - return when (n) { - zero -> zero - one -> one - else -> fibs(n - one) + fibs(n - two) - } -} - -fun sequentialFibs(): Double { - val results = Array(3, { zero }) - return measureTimeMillis { - results[0] = fibs(36.big) - results[1] = fibs(37.big) - results[2] = fibs(38.big) - }.toDouble() -} - -fun parallelFibs() = runBlocking { - val results = Array(3, { zero }) - measureTimeMillis { - val a = launch { - results[0] = fibs(36.big) - } - val b = launch { - results[1] = fibs(37.big) - } - val c = launch { - results[2] = fibs(38.big) - } - a.join() - b.join() - c.join() - }.toDouble() -} - -fun main() { - val seq = sequentialFibs() - val par = parallelFibs() - println("Ratio: ${round2dp(seq / par)}") -} -/* Sample output: (2 core machine) -Ratio: 1.68 -*/ -/* Sample output: (4 core machine) -Ratio: 1.94 -*/ \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/FibonacciSequence.kt b/Concurrency/Coroutines/Examples/src/FibonacciSequence.kt deleted file mode 100644 index 5f5cf955..00000000 --- a/Concurrency/Coroutines/Examples/src/FibonacciSequence.kt +++ /dev/null @@ -1,16 +0,0 @@ -// Coroutines/FibonacciSequence.kt -import atomictest.eq -import bigint.* -import kotlin.coroutines.* - -fun main() { - val fibonacciSeq = sequence { - var n = Pair(zero, one) - while (true) { - yield(n.first) - n = Pair(n.second, n.first + n.second) - } - } - fibonacciSeq.take(101).last() eq - "354224848179261915075".big -} \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/HelloCoroutines.kt b/Concurrency/Coroutines/Examples/src/HelloCoroutines.kt deleted file mode 100644 index 6bfb9be9..00000000 --- a/Concurrency/Coroutines/Examples/src/HelloCoroutines.kt +++ /dev/null @@ -1,16 +0,0 @@ -// Coroutines/HelloCoroutines.kt -import kotlinx.coroutines.* - -fun main() = - runBlocking { - val coroutine = launch { - delay(10) - println("Hello,") - } - println("World!") - coroutine.join() - } -/* Output: -World! -Hello, -*/ \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/LaunchMany.kt b/Concurrency/Coroutines/Examples/src/LaunchMany.kt deleted file mode 100644 index 74850f13..00000000 --- a/Concurrency/Coroutines/Examples/src/LaunchMany.kt +++ /dev/null @@ -1,16 +0,0 @@ -// Coroutines/LaunchMany.kt -import kotlinx.coroutines.* - -fun main() = - runBlocking { - val jobs = List(19) { - launch { - delay(1000) - print("$it ") - } - } - jobs.forEach { it.join() } - } -/* Sample output: -6 1 10 7 2 4 9 12 13 14 15 17 16 18 3 0 5 11 8 -*/ \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/LaunchManyTimed.kt b/Concurrency/Coroutines/Examples/src/LaunchManyTimed.kt deleted file mode 100644 index 341b4e2d..00000000 --- a/Concurrency/Coroutines/Examples/src/LaunchManyTimed.kt +++ /dev/null @@ -1,21 +0,0 @@ -// Coroutines/LaunchManyTimed.kt -import kotlinx.coroutines.* -import kotlin.system.measureTimeMillis - -fun main() = - runBlocking { - val duration = measureTimeMillis { - val jobs = List(19) { - launch { - delay(1000) - print("$it ") - } - } - jobs.forEach { it.join() } - } - println("\nDuration: $duration") - } -/* Sample output: -4 6 0 3 1 5 2 8 10 13 14 16 17 18 11 12 7 9 15 -Duration: 1020 -*/ \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/src/LazySequence.kt b/Concurrency/Coroutines/Examples/src/LazySequence.kt deleted file mode 100644 index 3fa58506..00000000 --- a/Concurrency/Coroutines/Examples/src/LazySequence.kt +++ /dev/null @@ -1,15 +0,0 @@ -// Coroutines/LazySequence.kt -import atomictest.eq -import kotlin.coroutines.* - -val items = listOf( - 1, 19, 34, 22, 97, 11, 72) - -fun main() { - val squares = sequence { - for (n in items) - yield(n * n) - } - squares.toList() eq - "[1, 361, 1156, 484, 9409, 121, 5184]" -} \ No newline at end of file diff --git a/Concurrency/Coroutines/Examples/task-info.yaml b/Concurrency/Coroutines/Examples/task-info.yaml deleted file mode 100644 index 77b50f08..00000000 --- a/Concurrency/Coroutines/Examples/task-info.yaml +++ /dev/null @@ -1,16 +0,0 @@ -type: theory -files: -- name: src/HelloCoroutines.kt - visible: true -- name: src/LaunchMany.kt - visible: true -- name: src/LaunchManyTimed.kt - visible: true -- name: src/CompareDelayingTask.kt - visible: true -- name: src/CompareSlowFib.kt - visible: true -- name: src/LazySequence.kt - visible: true -- name: src/FibonacciSequence.kt - visible: true diff --git a/Concurrency/Coroutines/Examples/task.md b/Concurrency/Coroutines/Examples/task.md deleted file mode 100644 index 9c7c9970..00000000 --- a/Concurrency/Coroutines/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Coroutines - -Examples accompanying the atom. \ No newline at end of file diff --git a/Concurrency/Coroutines/lesson-info.yaml b/Concurrency/Coroutines/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Concurrency/Coroutines/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Concurrency/async and await/Examples/src/TeaPartyTexting.kt b/Concurrency/async and await/Examples/src/TeaPartyTexting.kt deleted file mode 100644 index e735d15c..00000000 --- a/Concurrency/async and await/Examples/src/TeaPartyTexting.kt +++ /dev/null @@ -1,34 +0,0 @@ -// asyncandawait/TeaPartyTexting.kt -package asyncandawait - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.delay -import kotlinx.coroutines.runBlocking - -fun main() = runBlocking(Dispatchers.Default) { - val marchHare = async { - println("Can you bring the cake?") - delay(3000) - println("Yes, I can bring the cake!") - "cake" - } - val madHatter = async { - println("Can you bring the treacle?") - delay(2000) - println("Yes, I can bring the treacle!") - "treacle" - } - val doorMouse = async { - println("Can you bring the tea?") - delay(1000) - println("Yes, I can bring the tea!") - "tea" - } - println("Alice prepares for the party") - delay(1500) - println("Ready for the party") - println(doorMouse.await()) - println(madHatter.await()) - println(marchHare.await()) -} \ No newline at end of file diff --git a/Concurrency/async and await/Examples/task-info.yaml b/Concurrency/async and await/Examples/task-info.yaml deleted file mode 100644 index 71fe98b8..00000000 --- a/Concurrency/async and await/Examples/task-info.yaml +++ /dev/null @@ -1,4 +0,0 @@ -type: theory -files: -- name: src/TeaPartyTexting.kt - visible: true diff --git a/Concurrency/async and await/Examples/task.md b/Concurrency/async and await/Examples/task.md deleted file mode 100644 index 3f46a88d..00000000 --- a/Concurrency/async and await/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## `async` and `await` - -Examples accompanying the atom. \ No newline at end of file diff --git a/Concurrency/async and await/lesson-info.yaml b/Concurrency/async and await/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Concurrency/async and await/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Concurrency/section-info.yaml b/Concurrency/section-info.yaml deleted file mode 100644 index 75efb254..00000000 --- a/Concurrency/section-info.yaml +++ /dev/null @@ -1,3 +0,0 @@ -content: -- async and await -- Coroutines diff --git a/Language Interoperability/Collections & Java/Examples/src/CollectionStructure.kt b/Language Interoperability/Collections & Java/Examples/src/CollectionStructure.kt deleted file mode 100644 index a0e5b8ab..00000000 --- a/Language Interoperability/Collections & Java/Examples/src/CollectionStructure.kt +++ /dev/null @@ -1,14 +0,0 @@ -// CollectionsAndJava/CollectionStructure.kt -package collectionsandjava - -interface Collection -interface List: Collection -interface Set: Collection -interface Map - -interface MutableCollection -interface MutableList: - List, MutableCollection -interface MutableSet: - Set, MutableCollection -interface MutableMap: Map \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/Examples/src/HiddenArrayList.kt b/Language Interoperability/Collections & Java/Examples/src/HiddenArrayList.kt deleted file mode 100644 index ecc3f465..00000000 --- a/Language Interoperability/Collections & Java/Examples/src/HiddenArrayList.kt +++ /dev/null @@ -1,8 +0,0 @@ -// CollectionsAndJava/HiddenArrayList.kt -import atomictest.eq - -fun main() { - val list = mutableListOf(1, 2, 3) - list.javaClass.name eq - "java.util.ArrayList" -} \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/Examples/src/ImmutableByDefault.kt b/Language Interoperability/Collections & Java/Examples/src/ImmutableByDefault.kt deleted file mode 100644 index 332137f4..00000000 --- a/Language Interoperability/Collections & Java/Examples/src/ImmutableByDefault.kt +++ /dev/null @@ -1,14 +0,0 @@ -// CollectionsAndJava/ImmutableByDefault.kt -package collectionsandjava - -data class Animal(val name: String) - -interface Zoo { - fun viewAnimals(): Collection -} - -fun visitZoo(zoo: Zoo) { - val animals = zoo.viewAnimals() - // Compile-time error: - // animals.add(Animal("Grumpy Cat")) -} \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/Examples/src/JavaList.kt b/Language Interoperability/Collections & Java/Examples/src/JavaList.kt deleted file mode 100644 index aaee2a26..00000000 --- a/Language Interoperability/Collections & Java/Examples/src/JavaList.kt +++ /dev/null @@ -1,7 +0,0 @@ -// CollectionsAndJava/JavaList.kt -import atomictest.eq - -fun main() { - val list = listOf(1, 2, 3) - (list is java.util.List<*>) eq true -} \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/Examples/src/ReadOnlyCollections.kt b/Language Interoperability/Collections & Java/Examples/src/ReadOnlyCollections.kt deleted file mode 100644 index ad1cfe49..00000000 --- a/Language Interoperability/Collections & Java/Examples/src/ReadOnlyCollections.kt +++ /dev/null @@ -1,11 +0,0 @@ -// CollectionsAndJava/ReadOnlyCollections.kt -import atomictest.eq - -fun main() { - val mutableList = mutableListOf(1, 2, 3) - // Read-only reference to a mutable list: - val list: List = mutableList - mutableList += 4 - // list has changed: - list eq "[1, 2, 3, 4]" -} \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/Examples/task-info.yaml b/Language Interoperability/Collections & Java/Examples/task-info.yaml deleted file mode 100644 index 3a7a06e0..00000000 --- a/Language Interoperability/Collections & Java/Examples/task-info.yaml +++ /dev/null @@ -1,12 +0,0 @@ -type: theory -files: -- name: src/HiddenArrayList.kt - visible: true -- name: src/ImmutableByDefault.kt - visible: true -- name: src/CollectionStructure.kt - visible: true -- name: src/JavaList.kt - visible: true -- name: src/ReadOnlyCollections.kt - visible: true diff --git a/Language Interoperability/Collections & Java/Examples/task.md b/Language Interoperability/Collections & Java/Examples/task.md deleted file mode 100644 index a101e884..00000000 --- a/Language Interoperability/Collections & Java/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Collections & Java - -Examples accompanying the atom. \ No newline at end of file diff --git a/Language Interoperability/Collections & Java/lesson-info.yaml b/Language Interoperability/Collections & Java/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Language Interoperability/Collections & Java/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/AnnotateThrows.kt b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/AnnotateThrows.kt deleted file mode 100644 index 59c4276f..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/AnnotateThrows.kt +++ /dev/null @@ -1,8 +0,0 @@ -// ExceptionHandling/AnnotateThrows.kt -package checked -import java.io.IOException - -@Throws(IOException::class) -fun hasCheckedException() { - throw IOException() -} \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/CatchChecked.java b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/CatchChecked.java deleted file mode 100644 index 51cd035b..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/CatchChecked.java +++ /dev/null @@ -1,14 +0,0 @@ -// ExceptionHandling/CatchChecked.java -import checked.AnnotateThrowsKt; -import java.io.IOException; -import static atomictest.AtomicTestKt.eq; - -public class CatchChecked { - public static void main(String[] args) { - try { - AnnotateThrowsKt.hasCheckedException(); - } catch(IOException e) { - eq(e, "java.io.IOException"); - } - } -} \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/JavaChecked.java b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/JavaChecked.java deleted file mode 100644 index 95fced8d..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/ExceptionHandling/JavaChecked.java +++ /dev/null @@ -1,33 +0,0 @@ -// ExceptionHandling/JavaChecked.java -import java.io.*; -import java.nio.file.*; -import static atomictest.AtomicTestKt.eq; - -public class JavaChecked { - // Build path to current source file, based - // on directory where Gradle is invoked: - static Path thisFile = Paths.get( - "Examples", "ExceptionHandling", - "JavaChecked.java"); - public static void main(String[] args) { - BufferedReader source = null; - try { - source = new BufferedReader( - new FileReader(thisFile.toFile())); - } catch(FileNotFoundException e) { - // Recover from file-open error - } - try { - String first = source.readLine(); - eq(first, "// ExceptionHandling/" + - "JavaChecked.java"); - } catch(IOException e) { - // Recover from read() error - } - try { - source.close(); - } catch(IOException e) { - // Recover from close() error - } - } -} \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/KotlinChecked.kt b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/KotlinChecked.kt deleted file mode 100644 index 7fdb28ef..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/KotlinChecked.kt +++ /dev/null @@ -1,10 +0,0 @@ -// ExceptionHandling/KotlinChecked.kt -import atomictest.eq -import java.io.File - -fun main() { - File("Examples/ExceptionHandling/" + - "KotlinChecked.kt") - .readLines()[0] eq - "// ExceptionHandling/KotlinChecked.kt" -} \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/WithCleanup.kt b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/WithCleanup.kt deleted file mode 100644 index 52fb9049..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/src/WithCleanup.kt +++ /dev/null @@ -1,21 +0,0 @@ -// ExceptionHandling/WithCleanup.kt -package withfunction - -class Cleanup(n: Int): AutoCloseable { - val id = n - val x = println("Create $id") - fun show() { println("Use $id")} - override fun close() = println("Close $id") -} - -fun main() { - with(Cleanup(1)) { show() } - Cleanup(2).use { it.show() } -} -/* Output: -Create 1 -Use 1 -Create 2 -Use 2 -Close 2 -*/ \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task-info.yaml b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task-info.yaml deleted file mode 100644 index 5814b4c9..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task-info.yaml +++ /dev/null @@ -1,12 +0,0 @@ -type: theory -files: -- name: src/ExceptionHandling/JavaChecked.java - visible: true -- name: src/KotlinChecked.kt - visible: true -- name: src/AnnotateThrows.kt - visible: true -- name: src/ExceptionHandling/CatchChecked.java - visible: true -- name: src/WithCleanup.kt - visible: true diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task.md b/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task.md deleted file mode 100644 index e27be88a..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Java Checked Exceptions & Kotlin - -Examples accompanying the atom. \ No newline at end of file diff --git a/Language Interoperability/Java Checked Exceptions & Kotlin/lesson-info.yaml b/Language Interoperability/Java Checked Exceptions & Kotlin/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Language Interoperability/Java Checked Exceptions & Kotlin/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigFibonacci.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigFibonacci.kt deleted file mode 100644 index 996317d7..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigFibonacci.kt +++ /dev/null @@ -1,25 +0,0 @@ -// AdaptingJava/BigFibonacci.kt -package adaptingjava -import atomictest.eq -import bigint.* - -fun fibonacci(n: Int): BigInt { - tailrec fun fibonacci( - n: Int, - current: BigInt, - next: BigInt - ): BigInt { - if (n == 0) return current - return fibonacci( - n - 1, next, current + next) - } - return fibonacci(n, zero, one) -} - -fun main() { - (0..7).map { fibonacci(it) } eq - "[0, 1, 1, 2, 3, 5, 8, 13]" - fibonacci(22) eq 17711.big - fibonacci(150) eq - "9969216677189303386214405760200".big -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigInt.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigInt.kt deleted file mode 100644 index 92699215..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/BigInt.kt +++ /dev/null @@ -1,15 +0,0 @@ -// AdaptingJava/BigInt.kt -package bigint -import java.math.BigInteger - -typealias BigInt = BigInteger - -val Int.big: BigInt - get() = BigInt.valueOf(toLong()) - -val String.big: BigInt - get() = BigInt(this) - -val zero = BigInt.ZERO -val one = BigInt.ONE -val two = 2.big \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/ChangeName.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/ChangeName.kt deleted file mode 100644 index ddfc3d74..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/ChangeName.kt +++ /dev/null @@ -1,5 +0,0 @@ -// fromjava/ChangeName.kt -@file:JvmName("Utils") -package mypackage - -fun salad() = "Lettuce!" \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/ExtensionsToJavaClass.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/ExtensionsToJavaClass.kt deleted file mode 100644 index b11b8b9f..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/ExtensionsToJavaClass.kt +++ /dev/null @@ -1,17 +0,0 @@ -// fromkotlin/ExtensionsToJavaClass.kt -package fromkotlin -import atomictest.eq - -fun Chameleon.adjustToTemperature( - isHot: Boolean -) { - color = if (isHot) "grey" else "black" -} - -fun main() { - val chameleon = Chameleon() - chameleon.size = 2 - chameleon.size - chameleon.adjustToTemperature(isHot = true) - chameleon.color eq "grey" -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinClass.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinClass.kt deleted file mode 100644 index d39f142c..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinClass.kt +++ /dev/null @@ -1,7 +0,0 @@ -// fromjava/KotlinClass.kt -package mypackage - -class Basic { - var property1 = 1 - fun value() = property1 * 10 -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinDataClass.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinDataClass.kt deleted file mode 100644 index f8435819..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/KotlinDataClass.kt +++ /dev/null @@ -1,7 +0,0 @@ -// fromjava/KotlinDataClass.kt -package fromjava - -data class Data( - var name: String, - var age: Int -) \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/Random.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/Random.kt deleted file mode 100644 index b33e99c0..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/Random.kt +++ /dev/null @@ -1,8 +0,0 @@ -// fromkotlin/Random.kt -import atomictest.eq -import java.util.Random - -fun main() { - val rand = Random(47) - rand.nextInt(100) eq 58 -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/TopLevelFunction.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/TopLevelFunction.kt deleted file mode 100644 index 17928b6b..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/TopLevelFunction.kt +++ /dev/null @@ -1,4 +0,0 @@ -// fromjava/TopLevelFunction.kt -package mypackage - -fun hi() = "Hello!" \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/UseBeanClass.kt b/Language Interoperability/Mixing Kotlin & Java/Examples/src/UseBeanClass.kt deleted file mode 100644 index 824fe84d..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/UseBeanClass.kt +++ /dev/null @@ -1,13 +0,0 @@ -// fromkotlin/UseBeanClass.kt -import fromkotlin.Chameleon -import atomictest.eq - -fun main() { - val chameleon = Chameleon() - chameleon.size = 1 - chameleon.size eq 1 - chameleon.color = "green" - chameleon.color eq "green" - chameleon.color = "turquoise" - chameleon.color eq "turquoise" -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction.java deleted file mode 100644 index c67d17ff..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction.java +++ /dev/null @@ -1,10 +0,0 @@ -// fromjava/CallTopLevelFunction.java -package fromjava; -import mypackage.TopLevelFunctionKt; -import static atomictest.AtomicTestKt.eq; - -public class CallTopLevelFunction { - public static void main(String[] args) { - eq(TopLevelFunctionKt.hi(), "Hello!"); - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction2.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction2.java deleted file mode 100644 index a70b848e..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/CallTopLevelFunction2.java +++ /dev/null @@ -1,10 +0,0 @@ -// fromjava/CallTopLevelFunction2.java -package fromjava; -import static mypackage.TopLevelFunctionKt.hi; -import static atomictest.AtomicTestKt.eq; - -public class CallTopLevelFunction2 { - public static void main(String[] args) { - eq(hi(), "Hello!"); - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/MakeSalad.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/MakeSalad.java deleted file mode 100644 index 40a927b4..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/MakeSalad.java +++ /dev/null @@ -1,10 +0,0 @@ -// fromjava/MakeSalad.java -package fromjava; -import mypackage.Utils; -import static atomictest.AtomicTestKt.eq; - -public class MakeSalad { - public static void main(String[] args) { - eq(Utils.salad(), "Lettuce!"); - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingDataClass.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingDataClass.java deleted file mode 100644 index b5861e00..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingDataClass.java +++ /dev/null @@ -1,24 +0,0 @@ -// fromjava/UsingDataClass.java -package fromjava; -import java.util.HashMap; -import static atomictest.AtomicTestKt.eq; - -public class UsingDataClass { - public static void main(String[] args) { - Data d = new Data("Alice", 22); - String name = d.getName(); - d.setName("Bob"); - int age = d.getAge(); - d.setAge(age + 1); - // toString(): - eq(d, "Data(name=Bob, age=23)"); - HashMap hm = - new HashMap<>(); - hm.put(d, 47); - // Data objects work as hash keys: - eq((double)hm.get(d), (double)47); - // Call copy() from the Data class: - Data d2 = d.copy("Sam", 24); - eq(d2, "Data(name=Sam, age=24)"); - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingKotlinClass.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingKotlinClass.java deleted file mode 100644 index 47ddf8f9..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromjava/UsingKotlinClass.java +++ /dev/null @@ -1,13 +0,0 @@ -// fromjava/UsingKotlinClass.java -package fromjava; -import mypackage.Basic; -import static atomictest.AtomicTestKt.eq; - -public class UsingKotlinClass { - public static void main(String[] args) { - Basic b = new Basic(); - eq(b.getProperty1(), 1); - b.setProperty1(12); - eq(b.value(), 120); - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromkotlin/Chameleon.java b/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromkotlin/Chameleon.java deleted file mode 100644 index 187a210b..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/src/fromkotlin/Chameleon.java +++ /dev/null @@ -1,21 +0,0 @@ -// fromkotlin/Chameleon.java -package fromkotlin; -import java.io.Serializable; - -public class -Chameleon implements Serializable { - private int size; - private String color; - public int getSize() { - return size; - } - public void setSize(int newSize) { - size = newSize; - } - public String getColor() { - return color; - } - public void setColor(String newColor) { - color = newColor; - } -} \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/task-info.yaml b/Language Interoperability/Mixing Kotlin & Java/Examples/task-info.yaml deleted file mode 100644 index 885bf8fb..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/task-info.yaml +++ /dev/null @@ -1,32 +0,0 @@ -type: theory -files: -- name: src/Random.kt - visible: true -- name: src/fromkotlin/Chameleon.java - visible: true -- name: src/UseBeanClass.kt - visible: true -- name: src/ExtensionsToJavaClass.kt - visible: true -- name: src/KotlinClass.kt - visible: true -- name: src/fromjava/UsingKotlinClass.java - visible: true -- name: src/KotlinDataClass.kt - visible: true -- name: src/fromjava/UsingDataClass.java - visible: true -- name: src/TopLevelFunction.kt - visible: true -- name: src/fromjava/CallTopLevelFunction.java - visible: true -- name: src/fromjava/CallTopLevelFunction2.java - visible: true -- name: src/ChangeName.kt - visible: true -- name: src/fromjava/MakeSalad.java - visible: true -- name: src/BigInt.kt - visible: true -- name: src/BigFibonacci.kt - visible: true diff --git a/Language Interoperability/Mixing Kotlin & Java/Examples/task.md b/Language Interoperability/Mixing Kotlin & Java/Examples/task.md deleted file mode 100644 index f8a989ea..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Mixing Kotlin & Java - -Examples accompanying the atom. \ No newline at end of file diff --git a/Language Interoperability/Mixing Kotlin & Java/lesson-info.yaml b/Language Interoperability/Mixing Kotlin & Java/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Language Interoperability/Mixing Kotlin & Java/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Language Interoperability/Nullability Annotations/Examples/src/AnnotatedJava.kt b/Language Interoperability/Nullability Annotations/Examples/src/AnnotatedJava.kt deleted file mode 100644 index d277c2a0..00000000 --- a/Language Interoperability/Nullability Annotations/Examples/src/AnnotatedJava.kt +++ /dev/null @@ -1,20 +0,0 @@ -// NullabilityAnnotations/AnnotatedJava.kt -package nullabilityannotations -import javacode.AnnotatedJTool -import atomictest.eq - -object KotlinCode { - val a = AnnotatedJTool.getSafe("") - // Won't compile: - // val b = AnnotatedJTool.getSafe(null) - val c = AnnotatedJTool.getUnsafe("") - val d = AnnotatedJTool.getUnsafe(null) -} - -fun main() { - with(KotlinCode) { - ::a.returnType eq "javacode.JTool" - ::c.returnType eq "javacode.JTool?" - ::d.returnType eq "javacode.JTool?" - } -} \ No newline at end of file diff --git a/Language Interoperability/Nullability Annotations/Examples/src/javacode/AnnotatedJTool.java b/Language Interoperability/Nullability Annotations/Examples/src/javacode/AnnotatedJTool.java deleted file mode 100644 index 7690345a..00000000 --- a/Language Interoperability/Nullability Annotations/Examples/src/javacode/AnnotatedJTool.java +++ /dev/null @@ -1,21 +0,0 @@ -// javacode/AnnotatedJTool.java -package javacode; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class AnnotatedJTool { - @Nullable - public static JTool - getUnsafe(@Nullable String s) { - if(s == null) return null; - return getSafe(s); - } - @NotNull - public static JTool - getSafe(@NotNull String s) { - return new JTool(); - } - public String method() { - return "Success"; - } -} \ No newline at end of file diff --git a/Language Interoperability/Nullability Annotations/Examples/task-info.yaml b/Language Interoperability/Nullability Annotations/Examples/task-info.yaml deleted file mode 100644 index 186c4c8e..00000000 --- a/Language Interoperability/Nullability Annotations/Examples/task-info.yaml +++ /dev/null @@ -1,6 +0,0 @@ -type: theory -files: -- name: src/javacode/AnnotatedJTool.java - visible: true -- name: src/AnnotatedJava.kt - visible: true diff --git a/Language Interoperability/Nullability Annotations/Examples/task.md b/Language Interoperability/Nullability Annotations/Examples/task.md deleted file mode 100644 index b063b632..00000000 --- a/Language Interoperability/Nullability Annotations/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Nullability Annotations - -Examples accompanying the atom. \ No newline at end of file diff --git a/Language Interoperability/Nullability Annotations/lesson-info.yaml b/Language Interoperability/Nullability Annotations/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Language Interoperability/Nullability Annotations/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Language Interoperability/Nullable Types & Java/Examples/src/NPEOnPlatformType.kt b/Language Interoperability/Nullable Types & Java/Examples/src/NPEOnPlatformType.kt deleted file mode 100644 index 7216b361..00000000 --- a/Language Interoperability/Nullable Types & Java/Examples/src/NPEOnPlatformType.kt +++ /dev/null @@ -1,19 +0,0 @@ -// PlatformTypes/NPEOnPlatformType.kt -import javacode.JTool -import atomictest.* - -fun main() { - val xn = JTool.get(null) // [1] - xn?.method() eq null // [2] - capture { - xn.method() // [3] - } eq "NullPointerException" - - val yn: JTool? = JTool.get(null) // [4] - yn?.method() eq null - - capture { - val zn: JTool = JTool.get(null) // [5] - } eq "IllegalStateException: " + - "JTool.get(null) must not be null" -} \ No newline at end of file diff --git a/Language Interoperability/Nullable Types & Java/Examples/src/PlatformTypes.kt b/Language Interoperability/Nullable Types & Java/Examples/src/PlatformTypes.kt deleted file mode 100644 index e37a8e86..00000000 --- a/Language Interoperability/Nullable Types & Java/Examples/src/PlatformTypes.kt +++ /dev/null @@ -1,21 +0,0 @@ -// PlatformTypes/PlatformTypes.kt -import javacode.JTool -import atomictest.eq - -object KotlinCode { - val a: JTool? = JTool.get("") // [1] - val b: JTool = JTool.get("") // [2] - val c = JTool.get("") // [3] -} - -fun main() { - with(KotlinCode) { - a?.method() eq "Success" // [4] - b.method() eq "Success" - c.method() eq "Success" // [5] - ::a.returnType eq "javacode.JTool?" - ::b.returnType eq "javacode.JTool" - ::c.returnType eq - "javacode.JTool!" // [6] - } -} \ No newline at end of file diff --git a/Language Interoperability/Nullable Types & Java/Examples/src/javacode/JTool.java b/Language Interoperability/Nullable Types & Java/Examples/src/javacode/JTool.java deleted file mode 100644 index fb74e311..00000000 --- a/Language Interoperability/Nullable Types & Java/Examples/src/javacode/JTool.java +++ /dev/null @@ -1,12 +0,0 @@ -// javacode/JTool.java -package javacode; - -public class JTool { - public static JTool get(String s) { - if(s == null) return null; - return new JTool(); - } - public String method() { - return "Success"; - } -} \ No newline at end of file diff --git a/Language Interoperability/Nullable Types & Java/Examples/task-info.yaml b/Language Interoperability/Nullable Types & Java/Examples/task-info.yaml deleted file mode 100644 index d801c055..00000000 --- a/Language Interoperability/Nullable Types & Java/Examples/task-info.yaml +++ /dev/null @@ -1,8 +0,0 @@ -type: theory -files: -- name: src/javacode/JTool.java - visible: true -- name: src/PlatformTypes.kt - visible: true -- name: src/NPEOnPlatformType.kt - visible: true diff --git a/Language Interoperability/Nullable Types & Java/Examples/task.md b/Language Interoperability/Nullable Types & Java/Examples/task.md deleted file mode 100644 index 9a3ec485..00000000 --- a/Language Interoperability/Nullable Types & Java/Examples/task.md +++ /dev/null @@ -1,3 +0,0 @@ -## Nullable Types & Java - -Examples accompanying the atom. \ No newline at end of file diff --git a/Language Interoperability/Nullable Types & Java/lesson-info.yaml b/Language Interoperability/Nullable Types & Java/lesson-info.yaml deleted file mode 100644 index d8e63b88..00000000 --- a/Language Interoperability/Nullable Types & Java/lesson-info.yaml +++ /dev/null @@ -1,2 +0,0 @@ -content: -- Examples diff --git a/Language Interoperability/section-info.yaml b/Language Interoperability/section-info.yaml deleted file mode 100644 index dbbd647c..00000000 --- a/Language Interoperability/section-info.yaml +++ /dev/null @@ -1,6 +0,0 @@ -content: -- Mixing Kotlin & Java -- Java Checked Exceptions & Kotlin -- Nullable Types & Java -- Nullability Annotations -- Collections & Java diff --git a/course-info.yaml b/course-info.yaml index 3d8b1d8f..e2044685 100644 --- a/course-info.yaml +++ b/course-info.yaml @@ -9,7 +9,4 @@ content: - Functional Programming - Object-Oriented Programming - Preventing Failure -- Concurrency - Power Tools -- Advanced Topics -- Language Interoperability