Brian Nicholson
04/28/2021, 8:05 PMbuild.gradle.kts
specifically for Dokka with a sourceSet
containing just the subdirectory I'm interested in, and it generates documentation, but the problem is that any dependency outside of my sourceSet
is shown as <ERROR CLASS>
. Obviously, Dokka can't generate docs for these classes since it can't resolve them, but is there there any way to get these class names to appear as text rather than an error? Ideally, I'd be able to link these unresolved classes to a URL containing their source code, but even just getting the raw text name would be a huge improvement.Karlo Lozovina
04/28/2021, 8:07 PMequals()
for inline classes be available in the future?David Smith
04/29/2021, 9:51 AMRob Elliot
04/29/2021, 11:41 AM@Deprecated
but meaning specifically that a method call is pointless, because it returns this
and has the same return type as the object it is called on?
For instance, String.toString() = this
would be a candidate for it.user
04/29/2021, 12:30 PMeygraber
04/29/2021, 3:27 PMStefan Beyer
04/29/2021, 3:56 PM(19.999996 * 100.0).roundToInt().toDouble() / 100.0
is sometimes 20.0 and sometimes 0.0?
this is really unexpected ^^Gerard Bosch
04/29/2021, 5:25 PMUnresolved reference: of
sealed class Sealed {
// Is it possible to define a factory method or smart constructor here?
fun of(n: Int): Sealed = if (n > 0) Foo("test") else Bar(42)
data class Foo(val str: String) : Sealed()
data class Bar(val num: Number) : Sealed()
}
and why is the above not possible? thank you!Philipp Mayer
04/29/2021, 5:30 PMnkiesel
04/29/2021, 8:04 PMfor (line in lines) {
if (Regex("#(.) A (.+)").matches(line)) {
val m = Regex("#(.) A (.+)").matchEntire(line)
...
} else if (Regex("#(.) B (.+)").matches(line)) {
val m = Regex("#(.) B (.+)").matchEntire(line)
...
}
}
(real code of course has regexes defined only once etc.). I now changed it to
for (line in lines) {
val m1 = Regex("#(.) A (.+)").matchEntire(line)
if (m1 != null) {
...
continue
}
val m2 = Regex("#(.) B (.+)").matchEntire(line)
if (m2 != null) {
...
continue
}
}
but that does not look too nice (esp. the need for repeated continue
)Karlo Lozovina
04/29/2021, 8:30 PMlateinit
can't go on primary constructor parameters, is there a less manual way of doing something like this (lateinited class fields that can be set through the constructor)?:
class Foo(x: String? = null) {
lateinit var x: String
init {
if (x != null) this.x = x
}
fun show() = println("Foo: $x")
}
coroutinedispatcher
04/29/2021, 9:31 PMinvoke()
methods? For example:
class Whatever(val callbackNumber1: (SomeParameter) -> Unit, val callbackNumber2: () -> Unit)
So now when call that instance in another object, I would have something like this:
class AnotherObject : (SomeParameter) -> Unit , () -> Unit {
private val whatever = Whatever(this, this)
override fun invoke(){
}
override fun invoke(someParameter: SomeParameter){
}
}
Or should I just stick to plain interfaces in this case?Michael Böiers
04/30/2021, 12:46 PMif (foo?.isNotEmpty() ?: false) { … }
That works, but it’s not really concise. Wouldn’t it be better (and safe) if we could just write
if (foo?.isNotEmpty()) { … }
Cicero
04/30/2021, 3:52 PMTom Wayne
04/30/2021, 4:58 PMclient.webSocket(
port = 80,
method = HttpMethod.Get,
host = "<https://uat-betws.sts.pl>",
path = "/ticket?token=eyJzdWIiOiI0ZmY5Y2E1Mi02ZmEwLTRiYWYtODlhYS0wODM1NGE2MTU0YjYiLCJpYXQiOjE2MTk4MDAwNzgsImV4cCI6MTYxOTgwMzY3OH0.oIaXH-nFDpMklp4FSJWMtsM7ECSIfuNF99tTQxiEALM"
)
{
for (message in incoming) {
message as? Frame.Text ?: continue
val receivedText = message.readText()
println(receivedText)
}
// Consume all incoming websockets on this url
this.incoming.consumeAsFlow().collect {
logger.d("Received ticket status websocket of type ${it.frameType.name}")
if (it is Frame.Text) {
Json.decodeFromString<TicketStatusResponse>(it.readText())
}
}
}
Does somebody have any experience with ktor-websockets library? There is almost no documentation so maybe I am doing something wrong.
Thank youSlackbot
04/30/2021, 8:04 PMPatrick Ramsey
05/01/2021, 1:06 AMLastExceed
05/01/2021, 11:26 AMclass Thing(parameter: Int) : List<Int> by property { //unresolved reference: property
val property = listOf(parameter)
}
why isn't this allowed?Thorkild
05/01/2021, 6:39 PMBrian Dilley
05/01/2021, 8:12 PMMatěj Bystřický
05/01/2021, 11:25 PMLastExceed
05/02/2021, 3:12 PMconst
need to be specified explicitly? can't the compiler check automatically if the keyword is applicable ? or is there a scenario where you wouldn't want its optimizations ?Mark
05/03/2021, 2:09 AMfun (String.() -> Unit).test() {
"anything to demonstrate the point".apply {
// no code completion for "this" -> "this@test"
"something".this()
}
}
LastExceed
05/03/2021, 2:45 PMMap
that's guaranteed to be exhaustive, so the return type of get()
isn't nullable? (similar to how when
can skip else
when it's exhaustive)andreasmattsson
05/03/2021, 4:02 PMdata class TestContainer(
val body: Any?
)
operator fun TestContainer?.compareTo(b: TestContainer?): Int = this?.body.let { aBody ->
b?.body.let { bBody ->
when {
aBody is Boolean && bBody is Boolean -> {
val aBoolean: Boolean = aBody
val bBoolean: Boolean = bBody
return aBoolean.compareTo(bBoolean)
}
else -> -1
}
}
}
fun main() {
println("Comparison: ${TestContainer(true) < TestContainer(false)}")
}
But the following yields ClassCastException at runtime on JVM?
data class TestContainer(
val body: Any?
)
operator fun TestContainer?.compareTo(b: TestContainer?): Int = this?.body.let { aBody ->
b?.body.let { bBody ->
when {
aBody is Boolean && bBody is Boolean -> aBody.compareTo(bBody)
else -> -1
}
}
}
fun main() {
println("Comparison: ${TestContainer(true) < TestContainer(false)}")
}
Error is
Exception in thread "main" java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Number
I'd expect the two to be equivalent due to smart cast?Nthily
05/03/2021, 7:21 PMMainClass
in the jar I generated with Gradle
packageAndrew Gazelka
05/03/2021, 10:46 PMKirill Grouchnikov
05/03/2021, 10:49 PMMark
05/04/2021, 3:10 AMRegex
that will never find/match any input string? Seems that each regex engine out there has a different best practice for making an ‘impossible’ regex.df
05/04/2021, 1:35 PMdf
05/04/2021, 1:35 PMdave08
05/04/2021, 1:35 PMdf
05/04/2021, 1:36 PM