epabst
10/22/2019, 3:51 PMhttps://youtu.be/QyJZzq0v7Z4▾
KindRoacher
10/22/2019, 6:20 PMtseisel
10/22/2019, 6:45 PMmap
operation in the following sample :
sealed class Request<T> {
object Pending : Request<Nothing>()
class Success<T>(val result: T) : Request<T>()
class Failure(val error: Throwable) : Request<Nothing>()
}
val sourceFlow: Flow<Foo> = getFooFlow()
sourceFlow.map { Request.Success(it) as Request<Foo> }
.onStart { emit(Request.Pending) }
.catch { emit(Request.Failure(it) }
.onEach { ... }
.launchIn(scope)
Will this kind of issue be fixed by the new Kotlin inference ?
Or is there a workaround (other than creating a typed temporary variable) ?Slackbot
10/22/2019, 8:49 PMKyooSik Lee
10/23/2019, 4:55 AMkotlin
data class Foo(
val a: Int,
val b: String,
val c: Int
val d: Int
) {}
And I have another data class partialFoo, where I have partial fields of foo
kotlin
data class PartialFoo(
val a: Int,
val b: String
) {}
Is there any way that I can copy the fields of class instance of Foo
to class instance of PartialFoo
?Travis Griggs
10/23/2019, 5:36 AMTravis Griggs
10/23/2019, 5:37 AMjmillner_
10/23/2019, 8:23 AMJacky Android
10/23/2019, 8:57 AMSteve
10/23/2019, 5:53 PMTmpod
10/23/2019, 6:10 PMKrotick
10/24/2019, 5:36 AMval
attributes in the class constructor? I had to change everything to var
and I hate mutability ...libiez
10/24/2019, 12:20 PMMaxim Kizub
10/24/2019, 12:33 PMclass Wrapper<T> (val value: T) : T by value
?Ashutosh Panda
10/24/2019, 2:10 PMimport kotlin.random.Random
val x= Random().nextInt(from :1,until :7)
println(x)
why is this code showing incomplete code
Joan Colmenero
10/24/2019, 6:11 PMResultWrapper<out T>
but I'm curious now how to implement Either
on the execute method.
I found a way like
data class Success<out T : Any>(val value: T) : ResultWrapper<T>()
Travis Griggs
10/24/2019, 9:04 PMDavid Glasser
10/24/2019, 10:30 PMmhamade
10/25/2019, 7:03 AMczuckie
10/25/2019, 10:10 AM@JvmOverloads
on a data class constructor- it doesn’t seem that every permutation of the constructor is created to match default parametersmarschwar
10/25/2019, 1:02 PM> Could not resolve all files for configuration ':api:testCompileClasspath'.
> Could not find org.jetbrains.kotlin:kotlin-stdlib-common:1.3.60-eap-76.
Required by:
project :api > org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2-1.3.60-eap-76
> Could not find org.jetbrains.kotlin:kotlin-stdlib-common:1.3.60-eap-76.
Required by:
project :api > org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 > org.jetbrains.kotlin:kotlin-stdlib:1.3.50
project :api > org.jetbrains.kotlin:kotlin-test:1.3.50 > org.jetbrains.kotlin:kotlin-test-common:1.3.50
project :api > org.jetbrains.kotlin:kotlin-test-junit5:1.3.50 > org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.50
This is in the gradle file.
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'org.jetbrains.kotlin.jvm' version '1.3.50'
id "org.jetbrains.kotlin.plugin.spring" version "1.3.50"
}
allprojects {
apply plugin: 'kotlin'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin-spring'
repositories {
mavenCentral()
jcenter()
}
}
Is anyone else experiencing this? Any suggestions?Travis Griggs
10/25/2019, 3:07 PMas Hashmap
I get warnings/errors.
I feel like I’m missing some piece of the puzzle that it wasn’t obvious/apparent to me to put the as Hashmap there.Sujit
10/25/2019, 8:00 PMas?
it does not trigger the init {}
method, and I'm losing some info here when doing the casting from Serializable
<http://java.io|java.io>
interface that is setup in init{} block
. So, I'm wondering if there is a way to invoke the init {}
when casting with as?
?pavi2410
10/25/2019, 8:36 PMBen Madore
10/25/2019, 9:12 PMnwh
10/25/2019, 9:47 PMliminal
10/25/2019, 10:25 PMEllen Spertus
10/25/2019, 11:38 PMVoid!
?Alexander
10/26/2019, 9:20 AMmbonnin
10/26/2019, 12:30 PMfun <T> foo(aClass: java.lang.Class<T>): MutableList<T> {
return mutableListOf()
}
inline fun <reified T:Any> bar(t: T): MutableList<T> {
// fails here: expected: MutableList<T>, found: MutableList<out T>
return foo(t::class.java)
}
mbonnin
10/26/2019, 12:30 PMfun <T> foo(aClass: java.lang.Class<T>): MutableList<T> {
return mutableListOf()
}
inline fun <reified T:Any> bar(t: T): MutableList<T> {
// fails here: expected: MutableList<T>, found: MutableList<out T>
return foo(t::class.java)
}
karelpeeters
10/26/2019, 1:06 PMt
could have a subtype of T
, and so t::class.java
could be a subclass of Class<T>
and a MutableList
is invariant. The only thing you can do is make bar
return MutableList<out T>
which is correct.mbonnin
10/26/2019, 1:16 PMright, thanks !could have a subtype oft
T