This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| appConfig { | |
| config("ALPHA") { | |
| switch {/*...*/} | |
| range {/*...*/} | |
| editable {/*...*/} | |
| choice {/*...*/} | |
| } | |
| config("BETA") { | |
| switch {/*...*/} | |
| range {/*...*/} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| editable { | |
| key = "C" | |
| description = "C-D" | |
| currentValue = "C-V" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| range { | |
| key = "B" | |
| description = "B-D" | |
| min = 1 | |
| max = 100 | |
| currentValue = 50 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| switch { | |
| key = "A" | |
| description = "A-D" | |
| switchValue = false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| choice { | |
| key = "D" | |
| description = "D-D" | |
| currentChoiceIndex = 0 | |
| item { | |
| description = "E" | |
| } | |
| item { | |
| description = "F" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val fruitArray = arrayOf("Apple", "Banana", "Pear", "Grapes", "Strawberry") | |
| val kotlinChannel = Channel<String>() | |
| runBlocking { | |
| launch { | |
| for (fruit in fruitArray) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val fruitArray = arrayOf("Apple", "Banana", "Pear", "Grapes", "Strawberry") | |
| val kotlinChannel = Channel<String>() | |
| runBlocking { | |
| launch { | |
| for (fruit in fruitArray) { | |
| val wasSent = kotlinChannel.offer(fruit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val fruitArray = arrayOf("Apple", "Banana", "Pear", "Grapes", "Strawberry") | |
| val kotlinBufferedChannel = Channel<String>(2) | |
| runBlocking { | |
| launch { | |
| for (fruit in fruitArray) { | |
| kotlinBufferedChannel.send(fruit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ExperimentalCoroutinesApi | |
| fun main() { | |
| data class Fruit(override val name: String, override val color: String) : Item | |
| data class Vegetable(override val name: String, override val color: String) : Item | |
| // ------------ Helper Methods ------------ | |
| fun isFruit(item: Item) = item is Fruit | |
| fun isVegetable(item: Item) = item is Vegetable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * This is a class which implements a demultiplexer. It send each items | |
| * into the first channel with a predicate that evaluates true for it | |
| */ | |
| class Demultiplexer<E>(vararg val rules: Rule<E>) { | |
| suspend fun consume(receiveChannel: ReceiveChannel<E>) { | |
| for (item in receiveChannel) { | |
| // Receive the data from the channel | |
| for (rule in rules) { |