Sam
07/23/2021, 5:05 PMprivate var job: Job? = null
private fun scheduleJob() {
job?.cancel()
job = flow<Void> {
delay(mySpecifiDelay)
doWork()
}.launchIn(CoroutineScope(coroutineDispatcher))
}
Kareem Radwan
07/23/2021, 8:02 PMAlexey Yakovlev
07/24/2021, 10:36 AMPiotr Krzemiński
07/24/2021, 12:09 PMDanish Ansari
07/24/2021, 3:33 PMJgafner
07/25/2021, 8:04 AMli'lfluf
07/25/2021, 12:37 PM0xffff
? \U12345678
doesn't seem to workDirk Seewald
07/25/2021, 9:21 PMspierce7
07/26/2021, 3:55 AM.let {}
at the end of my when statements.Jason Roberts
07/27/2021, 5:14 AMiamthevoid
07/27/2021, 6:44 AMretry
function
fun <T, R> ((T, R) -> Unit).retry() {
this(argument1, argument2)
}
My real case a bit more complicated, here just extraction for clear my question.Zahara Vidumshikova
07/27/2021, 7:03 AMfun<T : Comparable<T>, K> comparePairByFirst() : Comparator<Pair<T, K>> = Comparator { p1, p2 -> p1.first.compareTo(p2.first) }
I have this code and it works, but creates a new similar comparator every use. I think it is bad. How can I make it better?
------------------------------------------------------------------------------------------------------------------------------------------------------------
How i can "this" method in inline functions? I want to get that class to log it.Zahara Vidumshikova
07/27/2021, 3:34 PMMichal Klimczak
07/27/2021, 4:04 PMemojiText.length
and I would like a method which returns 1
.Tomasz Krakowiak
07/27/2021, 4:46 PMError: Could not find or load main class org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
1.5.21 gradle plugin, tried different SDKs, upgrading plugin to 1.5.30-M1, downgrading to 1.5.20, 1.5.10. Cleaning project, removing whole $HOME/.gradle directory.
This error relates to submodule of multi-project project. Modules use either jvm or mpp plugin.Gopal S Akshintala
07/28/2021, 4:23 AMerror: cannot find symbol
# Kotlin Value class
import io.vavr.control.Either
import io.vavr.kotlin.right
@JvmInline
value class Name(val s: String) {
val length: Int
get() = s.length
}
fun getAsName(): Either<String, Name> = right(Name("Kotlin"))
# Java Client
@Test
void testValueClass() {
final var name = getAsName().get();
Assertions.assertEquals(0, name.getLength());
}
# Error
error: cannot find symbol
Assertions.assertEquals(0, name.getLength());
^
symbol: method getLength()
location: variable name of type Name
althaf
07/28/2021, 6:08 AMpackage com.abcd.registration
internal fun
Fragment.showUserAlreadyRegisteredOnAnotherDevice(actionProceedToRegister: (() -> Unit)?,
actionCancel: (() -> Unit)?) {
activity?.supportFragmentManager?.let {
var alreadyRegisterAnotherDeviceBottomSheet: AlreadyRegisterAnotherDeviceBottomSheet =
AlreadyRegisterAnotherDeviceBottomSheet.getInstance(
actionProceedToRegister,
actionCancel)
alreadyRegisterAnotherDeviceBottomSheet?.show(it, "BottomSheet")
}
}
I want this to be visible to only registration package any top level package should be able to use this extension even if they are inheriting from Fragment. Is this doable. I added internal keyword, still it is not working here. Any inputs ?Himani Vohra
07/28/2021, 6:59 AMmaarten ha
07/28/2021, 9:39 AMDanish Ansari
07/28/2021, 12:54 PMtoUpperCase()
and toLowerCase()
got deprecated in 1.5
uppercase()
and lowercase()
seems to have exactly same code, so why rename such a common method name after such stability of the language?Michael Nitschinger
07/28/2021, 4:06 PMJilles Soeters
07/28/2021, 8:08 PMspierce7
07/29/2021, 2:53 AMshouldEqual
, but the correct answer calls the function shouldMatch
. There were lots of small little mistakes in the correct answers that make you question whether or not it’s the correct answer.juliocbcotta
07/29/2021, 2:03 PM@file:JvmName("UriDeepLinkFactory")
...
fun UriDeepLink.Companion.from(uri: Uri): UriDeepLink {
return UriDeepLink(UriParameter(uri)) { scheme -> Schemes.valueOf(scheme) }
}
fun UriDeepLink.Companion.from(uriString: String): UriDeepLink {
return UriDeepLink.from(Uri.parse(uriString))
}
But when I try to access it from java I get the error at compile time
final UriDeepLink deepLink = UriDeepLinkFactory.from(operationDeepLink);
^
method UriDeepLinkFactory.from(Companion,Uri) is not applicable
(actual and formal argument lists differ in length)
method UriDeepLinkFactory.from(Companion,String) is not applicable
(actual and formal argument lists differ in length)
Any idea of how to fix it ?Jérémy CROS
07/29/2021, 2:05 PMKarlo Lozovina
07/29/2021, 7:07 PMabstract class A {
open val x: String? = null
}
sealed class B : A() {
override val x = "x"
}
class C : B() {
override val x = null
}
If I add a type annotation on B.x
of String?
, then it works...Travis Griggs
07/29/2021, 9:26 PM:large_blue_circle:
), Explicit this = :large_green_square: (:large_green_square:
)Kefas
07/30/2021, 5:17 AMfun main() {
val a: () -> Unit = { }
val b: () -> Unit = { }
val c = generateLambda()
val d = generateLambda()
println(a == b) // false
println(c == d) // true
}
fun generateLambda(): () -> Unit {
return { }
}
MrNiamh
07/30/2021, 8:46 AMclass A (
override val values: List<A>
) : B
interface B {
val values: List<B>
}
This does not:
class A (
override var values: List<A>
) : B
interface B {
var values: List<B>
}
Jomon G
07/30/2021, 8:51 AMJomon G
07/30/2021, 8:51 AM