v79
11/05/2018, 8:11 AMkotlin-stdlib-jre8
is only verison 1.2.71 in maven and marked as deprecated.nitrog42
11/05/2018, 10:44 AMmersan
11/05/2018, 10:55 AMrunBlocking {
val timer = measureTimeMillis { delay(1000) }
println("Delay Measure: $timer")
val timer2 = measureTimeMillis { Thread.sleep(1000) }
println("Thread Sleep Measure: $timer2")
}
but the result was unexpected for me:
Delay Measure: 1064
Thread Sleep Measure: 1002
Is it something I should expect the delay
in coroutine takes more time than the Thread.sleep
?jcechace
11/05/2018, 12:41 PMoverride fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) {
try {
customTm?.checkServerTrusted(chain, authType) ?: defaultTm.checkServerTrusted(chain, authType)
} catch (e : CertificateException) {
defaultTm.checkServerTrusted(chain, authType)
}
}
arve
11/05/2018, 1:33 PMval input: List<List<Double>> =
[[1, 2, 3 (....)],
[4, 5, 6, (...)],
[7, 8, 9, (...)]]
val expected= [12, 15, 18, (...)]
Trying to find an elegant way to sum elements of a list of list of numbers by index (i.e. "downwards")🤔diesieben07
11/05/2018, 1:34 PMinput.map { it.sum() }
?DJ Mitchell
11/05/2018, 4:01 PMExpressibleByXXXXLiteral
, so you can create a type and if you pass the correct type of literal as an argument the compiler will automatically lift that literal into the correct type. For instance one nice thing in Kotlin would be to be able to express an inline class
as a literal without having to explicitly initialize a type at the callsite:
inline class UserID(val value: Int) {}
data class User(val userID: UserID) {}
// would love to be able to do this
val user = User(5)
// instead i have to do this
val user = User(UserID(5))
gsala
11/05/2018, 4:05 PMUser
requires a UserID
to be constructed, it shouldn't be allowed to be constructed with any Int
John Dengis
11/05/2018, 6:03 PMpavel
11/06/2018, 12:07 AMval foo = listOf("foo", "bar", null, "")
val bar = foo.filter { !it.isNullOrEmpty() }
the compiler is arguing that bar
is List<String?>
while my position is that it should be List<String>
. Am I expecting too much from contracts? And is there a better way to write this?christophsturm
11/06/2018, 9:24 AMelect
11/06/2018, 10:16 AMlazy
is actually being executed twice: https://github.com/kotlin-graphics/uno-sdk/blob/master/src/main/kotlin/uno/awt/JawtDemo.kt#L79-L84elect
11/06/2018, 10:17 AMAPXEOLOG
11/06/2018, 1:38 PMjackson-module-kotlin
for now, but i face some issues there with kotlin support. Maybe there are some other simple to use and easily customisable solutionsvibin
11/06/2018, 2:46 PMpawel.urban
11/06/2018, 3:45 PMprivate val _title = BehaviorRelay.create<String>()
val title: Observable<String> = _title
without the backing property?dave08
11/06/2018, 4:15 PMval someSet: Set<String>? = setOf("this", "that", "this=3")
and I'd like to extract the 3 as an Int
, is this the most ideomatic/efficient way to do it?
someSet?.firstOrNull { it.startsWith("this=") }
?.substringAfter("this=")
?.toInt() ?: 0
coder82
11/06/2018, 4:35 PMmiha-x64
11/06/2018, 5:31 PMbreun
11/06/2018, 9:04 PMstkent
11/06/2018, 9:31 PMhttps://www.youtube.com/watch?v=bnRNiE_OVWA&t=10m55s▾
fun sieve(remainderSequence: Sequence<Int> = generateSequence(2) { it + 1 }): Sequence<Int> {
val newPrime = remainderSequence.first()
val newRemainderSequence = remainderSequence.filterNot { it % newPrime == 0 }
return sequence {
yield(newPrime)
}.plus(sieve(newRemainderSequence))
}
which I thought would remain lazy, but it appears not to. What am I missing?tateisu
11/07/2018, 1:54 AMZaidi
11/07/2018, 9:56 AMdeviant
11/07/2018, 10:54 AM::logger.isInitialized
or
logger==null
i mean should i avoid isInitialized
lateinit feature due to reflection magic?mikehearn
11/07/2018, 12:18 PMCamilleBC
11/07/2018, 12:55 PMCamilleBC
11/07/2018, 1:05 PMkarelpeeters
11/07/2018, 2:51 PMval str = "hey"
when (val line = str) {
"abc" -> println("abc")
line.startsWith("h") -> println("starts with h")
}
Any reason this doesn't work? It says Incompatible type: Boolean and String
on the .startsWith
part.karelpeeters
11/07/2018, 5:11 PMbeepdog
11/07/2018, 7:15 PMobject RTMMessages {
sealed class Message(val id: Long, val type: String, val channel: String){
class Typing() : Message(id, "typing", channel)
}
}
beepdog
11/07/2018, 7:15 PMobject RTMMessages {
sealed class Message(val id: Long, val type: String, val channel: String){
class Typing() : Message(id, "typing", channel)
}
}
dalexander
11/07/2018, 7:18 PMbeepdog
11/07/2018, 7:22 PMMessage
dalexander
11/07/2018, 7:27 PMbeepdog
11/07/2018, 8:07 PMdalexander
11/07/2018, 8:12 PM