Marcello Lelio Albano
06/17/2021, 11:14 PMmzgreen
06/18/2021, 6:25 AMval list = listOf(1,2,3,4,5)
when (list) {
all { it < 10 } -> foo()
any { it % 2 == 0 } -> bar()
else -> baz()
}
but it doesn't seem to be possible and I'm not sure why.igor.wojda
06/18/2021, 8:58 AMclass Container {
val view: View2 = View2()
var onClickListener:(() -> Unit)? by view.onClickListener // does not work
}
class View2 {
var onClickListener:(() -> Unit)? = null
}
Slackbot
06/18/2021, 11:12 AMQuantum64
06/18/2021, 1:19 PMHexa
06/18/2021, 5:53 PMimport java.time.Instant
import java.time.ZonedDateTime
fun main() {
val time = "2017-07-24 03:45:26 +0000 UTC"
val parsed1: ZonedDateTime = ZonedDateTime.parse(time) // fails
val parsed2: Instant = Instant.parse(time) // fails
}
}
Ayfri
06/19/2021, 7:00 AMAlfred Lopez
06/19/2021, 10:52 PMhisham bin awiad
06/20/2021, 12:21 PMWilliam Reed
06/21/2021, 1:23 PMblock
isn’t called 0 or 2+ times?
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
Vijayakumar M
06/21/2021, 2:34 PMval dispatcher = ScheduledThreadPoolExecutor(1).asCoroutineDispatcher()
val customScope = CoroutineScope(SupervisorJob() + dispatcher)
customScope.launch{
//This block works fine.
customScope.launch{
//This block is not executing
}
}
However it woks fine If I change the dispatcher in the inner block. But In my case, I need to have the same dispatcher in both launches.
Any help would be very much appreciated.Kirill Grouchnikov
06/21/2021, 7:04 PM{ change -> change.consumeDownChange() }
for the inner block?William Reed
06/21/2021, 8:34 PMvar a = true
var b = false
when (a, b) {
true, true -> ...
true, false -> ...
false, true -> ...
false, false -> ...
}
is this the best alternative?
when {
a, !b -> ...
}
Peter Ertl
06/23/2021, 8:38 AMlaith
06/23/2021, 2:29 PMeygraber
06/23/2021, 3:54 PMJosh Feinberg
06/23/2021, 7:13 PMCould not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
since we upgraded from 1.4.31 to 1.5.10 but i'm not sure what to file in a bug or anythingMatt Yokan
06/23/2021, 10:03 PMSangmin Lee
06/24/2021, 5:47 AMclass CustomFieldTypeA() {
var value: String = ""
private val charset: Charset = ACharset()
}
class CustomFieldTypeB() {
var value: String = ""
private val charset: Charset = BCharset()
}
data class TestData(
var field1: CustomFieldTypeA = null,
var field2: CustomFieldTypeB = null,
)
The reason to use CustomFieldType is to have charset for string. And I want to use this type in the same way to use String like below
// for setter
val obj = TestData()
obj.field1 = "hi type 1"
obj.field2 = "hi type 2"
// for getter
val str = obj.field1
print(str) // hi type 1
Is there any way to do like this? (maybe using delegate?)Stanislav Kral
06/24/2021, 8:17 AMConfigValidator.validate
method.
Any other comments or possible improvements to the code below are also welcome.
Thanks!
class ConfigValidator(private val configRules: List<Rule>) {
abstract class Rule {
abstract fun validateConfig(model: InitModel): RuleViolation?
}
fun validate(model: InitModel) = configRules.map {
// !!! is there any way to make this stop mapping items when the first RuleViolation is found? !!!
// this method needs to return "RuleViolation?"
it.validateConfig(model)
}.firstOrNull()
class SimpleRule1(...) : Rule() {
override fun validateConfig(model: InitModel): RuleViolation? =
model.items.firstOrNull {
// some condition for model item
}?.let {
RuleViolation(1, "Rule violation description")
}
}
class SimpleRule2(...) : Rule() {
override fun validateConfig(model: InitModel): RuleViolation? =
model.items.firstOrNull {
// some condition for model item
}?.let {
RuleViolation(2, "Rule 2 violation description")
}
}
class RuleViolation(val code: Int, message: String) : Exception(message)
}
Mjahangiry75
06/24/2021, 11:57 AMMatt Anger
06/24/2021, 5:37 PMeygraber
06/25/2021, 5:03 AMJvmField cannot be applied to a property of an inline class type. This warning will become an error in further releasesI didn't see this mentioned anywhere in the release notes (or the GitHub release). Is there something pointing to this?
MTM123
06/25/2021, 9:23 AMKasule Moses
06/25/2021, 4:55 PMVivek Modi
06/25/2021, 10:54 PMSam Garfinkel
06/26/2021, 1:41 AM@JvmInline
value class Bar(
val foo: Foo
)
fun Foo.doSomething() {
}
ERROR HERE >>> Bar(Foo()).doSomething()
Akshat Sharma
06/26/2021, 6:34 AMViet Nguyen Tran
06/26/2021, 7:17 AMAkshat Sharma
06/26/2021, 7:27 AM