droidrcc
05/26/2018, 5:27 PMdroidrcc
05/26/2018, 5:42 PMlouiscad
05/26/2018, 10:12 PMrobstoll
05/27/2018, 2:22 PMimport kotlin.also as alsoFromKotlin
infix fun <T> T.also(block: (T) -> Unit): T = alsoFromKotlin(block)
robstoll
05/27/2018, 2:23 PMkotlin.also(this, block)
would workkarelpeeters
05/27/2018, 8:46 PMdroidrcc
05/27/2018, 9:04 PMdroidrcc
05/27/2018, 9:06 PMdroidrcc
05/27/2018, 9:22 PMCzar
05/27/2018, 9:23 PMwarriorprincess
05/28/2018, 12:36 PMelse if
work though?avolkmann
05/28/2018, 2:31 PMwathek
05/29/2018, 12:46 AMclass Test<T: C1> {
fun getTypeName(): String {
// Return what is T
}
}
fun main(args: Array<String>) {
val t = Test<String>
println(t.getTypeName()) // Returns String
}
hallvard
05/29/2018, 1:41 PMwhen
cleans up my code. Used with in
, checking if an element is in a collection is very simple. Now have I overlooked the possibility of doing it the other way around? I.e. is it possible to do something like this (pseudo-code):
when (collection-of-strings) {
has "string 1" -> handleString1()
has "string 2" -> handleString2()
has "string 3" -> handleString3()
else -> throw Exception()
}
hanpari
05/29/2018, 4:12 PMSlackbot
05/29/2018, 4:22 PMkarelpeeters
05/29/2018, 4:31 PMdiesieben07
05/29/2018, 5:30 PMLex Luthra
05/30/2018, 1:39 AMmarkusa
05/30/2018, 9:58 AMwaqas
05/30/2018, 10:56 AMprivate void prepareLog(int priority, Throwable t, String message, Object... args) {
// Consume tag even when message is not loggable so that next message is correctly tagged.
String tag = getTag();
if (!isLoggable(tag, priority)) {
return;
}
if (message != null && message.length() == 0) {
message = null;
}
if (message == null) {
if (t == null) {
return; // Swallow message if it's null and there's no throwable.
}
message = getStackTraceString(t);
} else {
if (args != null && args.length > 0) {
message = formatMessage(message, args);
}
if (t != null) {
message += "\n" + getStackTraceString(t);
}
}
log(priority, tag, message, t);
}
GarouDan
05/30/2018, 1:32 PMrobstoll
05/30/2018, 3:15 PMAndrei
05/30/2018, 5:30 PMadams2
05/30/2018, 11:13 PMbissell
05/31/2018, 6:38 AM/**
* No locks are used to synchronize an access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.
*
* This mode should not be used unless the [Lazy] instance is guaranteed never to be initialized from more than one thread.
*/
Let's say my lazy
field is calculated from val
inputs on a data class by a deterministic, pure function. I don't mind potentially duplicating the work to calculate it in multiple threads, and would rather elide any synchronization costs. Is there any harm to using NONE
in this case? Maybe some weirdness around Kotlin Native I haven't considered?Lebohang
05/31/2018, 7:33 PMShawn
06/01/2018, 4:27 AMmembers.putIfAbsent(key, value)
rik
06/01/2018, 8:49 AMNgenge Senior
06/01/2018, 8:54 AMNgenge Senior
06/01/2018, 8:54 AMseetha
06/02/2018, 6:18 PMNgenge Senior
06/04/2018, 2:53 AM