Reprator
03/31/2020, 11:49 AMHamza
03/31/2020, 12:07 PM{statement}.{{templateName}}
? Similar to how doing something like
val x = "hi"
x.sout <Tab> // -> println(x)
ATM, I just duplicated the sout template and added my own, but it doens't work where I call it on another variable. Is that even possible?
So I can do something like
x.{{templateName}}<Tab> // -> Something.doSomething(x)
Edoardo Luppi
03/31/2020, 12:58 PM"""[ \t\f\v]+""".toRegex()
"[ \\t\\f\\v]+".toRegex()
sbyrne
03/31/2020, 2:02 PMprivate val done:MutableSet<T> = mutableSetOf()
in a class. Method a
starts a thread which calls method b
, which has synchronized(done)
. I intermittently get an NPE on synchronize(done)
. I moved the private val done
declaration from between a
and b
to above a
and that seems to have fixed it. Am I crazy?iex
03/31/2020, 2:58 PMequals
and hashcode
for a data class that contains a ByteArray
?Sam Garfinkel
03/31/2020, 5:55 PMval foo: String? by defaultProperty { null }
? It only goes away by explicitly defining the type of defaultProperty<String?>
Slackbot
04/01/2020, 5:48 AMChills
04/01/2020, 9:11 AMEdoardo Luppi
04/01/2020, 9:52 AMSequence<T>
myProviders
.asSequence()
.sortedBy(configService::getProviderOrder)
.flatMap { it.getCommitTypes(context.type) }
.map { CommitTypePsiElement(project, it) }
.mapIndexed(::CommitTypeLookupElement)
.distinctBy(CommitTypeLookupElement::getLookupString)
.forEach(rs::addElement)
Each provider
call (it.getCommitTypes(context.type)
) returns a Collection<T>
and cannot be converted to Flows.
I would like to call every provider asynchronously and then flatMap
the results, and collect
.
How would you approach this in the code above?
This part
.map { CommitTypePsiElement(project, it) }
.mapIndexed(::CommitTypeLookupElement)
.distinctBy(CommitTypeLookupElement::getLookupString)
.forEach(rs::addElement)
can remain sequential / blocking.user
04/01/2020, 10:43 AMulrikguenther
04/01/2020, 2:38 PMTwferrell
04/01/2020, 3:33 PMGunslingor
04/01/2020, 4:17 PMiex
04/01/2020, 8:08 PMfold
is less performant than a loop, right?
Specifically:
bytes.fold("") { acc, byte -> acc + String.format("%02X", byte) }
vs
var ret: String = ""
for (b in bytes) {
ret += String.format("%02X", b)
}
return ret
Chills
04/02/2020, 5:47 AMsteenooo
04/02/2020, 9:55 AMzalewski.se
04/02/2020, 12:31 PMlog(243.0, 3.0)
returns 4.999999999999999 😮Holger Steinhauer [Mod]
04/02/2020, 3:32 PMTwferrell
04/02/2020, 8:04 PMGilberto Diaz
04/03/2020, 1:39 AMChung
04/03/2020, 2:47 AMedge = Edge1(__typename=CmsCarouselImageEdge, .....)
and I would like to define my own data class data class MyClass
rather than return this variable as Edge1
. how do I do it in Kotlin?
val my_data: MyClass = edge as MyClass
Vitali Plagov
04/03/2020, 8:41 AMdata class ScopeGroup(
val id: UUID,
val scopeOptions: List<ScopeOption>
)
and
data class ScopeOption(
val id: UUID,
val status: String
)
So, the service returns a list of ScopeGroup
with several ScopeOption
inside. I want to filter this list so that ScopeGroup
has a list of only those ScopeOption
that has a certain status. I did this:
list.flatMap { group -> group.scopeOptions.filter { option -> option.status == "ACTIVE" } }
But it returns List<ScopeOption>
. Is it possible to return List<ScopeGroup>
instead?CFrei
04/03/2020, 8:47 AMclass A
class B
open class C
open class D
val a: A = A()
val c: C = C()
a is B // <-- as expected: error
c is D // <-- not expected: no error
As expected I get an "Incompatible types B and A"-error at compile time for the line a is B
. But not for the next line c is D
. Is there any chance that c
could be of type D
or is this a missing feature in the compiler? Does anyone have an example?Erik
04/03/2020, 10:21 AMval isString
, x
inside the if-statement cannot be smart cast to `String`:
val x: Any = "foo"
val isString = x is String
if (isString) {
x + "bar" // Error, cannot smart cast x to String
}
val y = isString
Which of the following two options is preferred and why, or is there another idiomatic way to do this?
🅰️:
val x: Any = "foo"
val isString = x is String
if (isString) {
x as String + "bar" // Dumb cast x to String
}
val y = isString
🅱️:
val x: Any = "foo"
if (x is String) {
x + "bar"
}
val y = x is String // Repeat the type check
You can vote 🅰️, 🅱️, or reply in the thread for reasons why (not) to go for 🅰️ or 🅱️, or another option. Thanks! 🙂vinay
04/03/2020, 10:55 AMw: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+InlineClasses
Grantas33
04/03/2020, 5:37 PMbmarinovic
04/03/2020, 7:12 PMgammax
04/04/2020, 4:09 PM-Werror
flag that will turn all warnings to errors. I’d love to raise only some of them. Do you have any ideas on where to investigate?Deanfarwell
04/04/2020, 5:37 PMimplementation "io.arrow-kt:arrow-core:$arrow_version"
Gunslingor
04/04/2020, 8:01 PMfun Any.jsonToString(prettyPrint: Boolean): String{
var thisJsonString = Klaxon().toJsonString(this)
var result = thisJsonString
if(prettyPrint) {
if(thisJsonString.startsWith("[")){
result = Klaxon().parseJsonArray(thisJsonString.reader()).toJsonString(true)
} else {
result = Klaxon().parseJsonObject(thisJsonString.reader()).toJsonString(true)
}
}
return result
}
routing {
route("report") {
route("get") {
get("all") {
call.respondText {
dbConnect()
val reports = transaction { Report.all().toList() }
Klaxon().jsonToString(reports)
}
}
Gunslingor
04/04/2020, 8:01 PMfun Any.jsonToString(prettyPrint: Boolean): String{
var thisJsonString = Klaxon().toJsonString(this)
var result = thisJsonString
if(prettyPrint) {
if(thisJsonString.startsWith("[")){
result = Klaxon().parseJsonArray(thisJsonString.reader()).toJsonString(true)
} else {
result = Klaxon().parseJsonObject(thisJsonString.reader()).toJsonString(true)
}
}
return result
}
routing {
route("report") {
route("get") {
get("all") {
call.respondText {
dbConnect()
val reports = transaction { Report.all().toList() }
Klaxon().jsonToString(reports)
}
}