CFrei
09/20/2020, 3:30 PMelect
09/21/2020, 9:32 AM.reversed()
) other than
for(i in g.windows.lastIndex downTo 0) {
val window = g.windows[i]
? Ps: I do need continue
and break
insideRomavic
09/21/2020, 12:11 PMHenry
09/21/2020, 1:12 PMMihael
09/21/2020, 1:20 PMAlberto
09/21/2020, 8:42 PMnanodeath
09/22/2020, 5:00 AMfoo::class
return KClass<out String>
instead of KClass<String>
, and...what are my options if I actually want the latter?Luc Girardin
09/22/2020, 9:45 AMimport kotlin.jvm.JvmField
open class X(
@JvmField
open val x : Int = 0,
) {
fun getX() : Int = x
}
open class XY(
@JvmField
val y : Int = 0
) : X()
Trying to compile this little piece of code for the JVM will produce the following error:
Inherited platform declarations clash: The following declarations have the same JVM signature (getX()I):
fun <get-x>(): Int defined in XY
fun getX(): Int defined in XY
It seems that the @JvmField defined in X is not inherited by the XY class. From my perspective, this construct is valid and very useful if one want to keep compatibility with an API that offers both field and method-based access... even though this is usually bad yet common practice.
Thanks for listening!
LucBor Monty
09/22/2020, 1:55 PMuser
09/22/2020, 3:04 PMJakob K
09/22/2020, 4:40 PMZusammenfassungABC
, even if it inherits from ZusammenfassungAC
(line 22)?Karlo Lozovina
09/23/2020, 1:21 PMlateinit
has isInitialized
to check if the field has been initialized, is there something similar for Delegates.notNull
?janvladimirmostert
09/23/2020, 7:23 PMclass TestClass {
init {
println("????????????")
}
companion object {
init {
println("!!!!!!!!!!!!!")
}
fun touch() {
// empty function to trigger init
}
}
}
object TestObject {
init {
println(">>>>>>>>>>>>>>>>>")
}
fun touch() {
// empty function to trigger init
}
}
In my main, i literally have to call touch before the TestObject and TestClass' init is called
@JvmStatic
fun main(args: Array<String>) {
TestClass.touch()
TestObject.touch()
}
i'm tryin to implement some form of inversion of control where classes register themselve to a central place
My use-case is building the equivalent of a Controller, but instead of wiring in URLs in a central place, each Controller wires itself in to the central pointLouis Saglio
09/23/2020, 7:50 PMrandom.choices
in python ?spand
09/24/2020, 8:07 AMDaniel Svensson
09/24/2020, 9:57 AMDaniel Svensson
09/24/2020, 9:59 AMDaniel Svensson
09/24/2020, 9:59 AMmikehearn
09/24/2020, 11:26 AMinternal
members showing up in auto-completion from Java projects?mikehearn
09/24/2020, 11:26 AMAnimesh Sahu
09/24/2020, 2:21 PMclass ElementRemoveEvent<E>(
val element: E,
override val collection: ObservableCollection<E>
) : Event<E>
And it is misbehaving as you can see in the screen shots, what is causing this and how do I get rid of it? Is it outcome of excessive type inference?Animesh Sahu
09/24/2020, 3:40 PMvineethraj49
09/24/2020, 4:25 PMdata class Test(
val a: String,
val b: String? = null
)
library A; 1.0.5
data class Test(
val a: String,
val b: String? = null,
val c: String? = null
)
library B; 1.0.1
-> library A; [1.0, 2.0) // when built -> 1.0.4
library C;
-> library B; [1.0, 2.0)
-> library A; [1.0, 2.0)
now, when building library C again;
-> library B; [1.0, 2.0) -> 1.0.1
-> library A; [1.0, 2.0) -> 1.0.5
here; given library A; 1.0.5 gets picked; the library C, when running, gives me java.lang.NoSuchMethodError: Test.<init>
when it should've ideally not (I think?)
can someone help me figure out why this is happening, and how I can mitigate this?Emmanuel Oga
09/25/2020, 3:29 AMbodiam
09/25/2020, 6:01 AMval myObject: MyClass? = map.ifKeyPresent("xyz) { return MyClass(it }.orElse { null }
So, basically, if a map contains the key, convert the value of that key to a different type, and if it’s not there, return something else, for example null
. Does something like this exist?louiscad
09/25/2020, 7:46 AMnaming
for the community to give and receive code naming help?
I'm thinking about code related names like symbols (functions, properties, classes, constants…), packages, modules, libraries, etc.Bilel El Oud
09/25/2020, 9:34 AMAnimesh Sahu
09/25/2020, 5:04 PMfun <T, E : SomeType<T>> function() {}
Then both T and E needed to be specifed
And for example this:
fun <T, E : SomeType<T>> function(v: T) {}
if we pass function(5)
(T) as one of the parameter then E is automatically taken as SomeType<T>, but why cannot we have half implicit parameter like function<Int>()
that could implicitly say about the second parameter?
Or does it exist, I'm just not noticing it?Cole K
09/25/2020, 8:59 PM@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION)
annotation class Navigate
Being used like
@Feature(Features.Login::class)
object Login: FeatureModel() {
override var featureItem = Config::loginFeature
override var action = ".login.open"
override var fallbackDisplayName = "Login"
override var requiresLogin = false
override var version = "1"
@Navigate
fun newInstance(): Intent {
return Intent("TEST")
}
}
But
Login::class.declaredFunctions.map { it.annotations }
Returns null in the evaluator. Any thoughts?Gabriel Santos
09/25/2020, 9:25 PM:core
and :common
, both of them are multiplatform supporting all existent platforms.
But when I try to add :common as a dependency to core, the build doesn't fail, but it's not imported, here's my build.gradle.kts in :core
plugins {
kotlin("multiplatform") apply true
}
repositories {
mavenCentral()
}
dependencies {
implementation(project(":common"))
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
js {
browser {
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by getting
val nativeTest by getting
}
}
Gabriel Santos
09/25/2020, 9:25 PM:core
and :common
, both of them are multiplatform supporting all existent platforms.
But when I try to add :common as a dependency to core, the build doesn't fail, but it's not imported, here's my build.gradle.kts in :core
plugins {
kotlin("multiplatform") apply true
}
repositories {
mavenCentral()
}
dependencies {
implementation(project(":common"))
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
js {
browser {
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by getting
val nativeTest by getting
}
}
edrd
09/26/2020, 2:05 AMcommonMain
source set?
https://kotlinlang.org/docs/reference/mpp-add-dependencies.htmlGabriel Santos
09/26/2020, 12:54 PM