Krystian Rybarczyk
12/07/2020, 8:54 PM@optics
sealed class AbstractUser : User() {
abstract val infos: List<UserInfo>
//subclassing data classes here
}
At some point I need to modify the infos
list and I don’t know which subtype it is. I don’t suppose it’s possible to use a lens here, is it?pakoito
12/08/2020, 1:40 AMKrystian Rybarczyk
12/08/2020, 9:12 AMpakoito
12/08/2020, 10:37 AMKrystian Rybarczyk
12/08/2020, 11:00 AMAbstractUser
and one inside FunnyUser
(a subclass). As I say: not a huge deal, but not ideal for me eitherpakoito
12/08/2020, 12:39 PMpakoito
12/08/2020, 12:39 PMsealed class Bla(val a: String)
class Ble(): Bla(a = "1")
object Miau: Bla(a = "33")
pakoito
12/08/2020, 12:40 PMBle().a // "1"
Miau.a // "33"
Krystian Rybarczyk
12/08/2020, 1:08 PMsealed class Bla(open val a: String) {
class Ble(override val a: String) : Bla(a)
object Miau: Bla(a = "33")
}
Bla.Miau.a
Bla.Ble("2").a
There will be only one a
for Bla
and Ble
accessible, but if you open it in debugger, each object has its own copy.
Does this matter for the optics at all though?pakoito
12/08/2020, 3:09 PMbut if you open it in debugger, each object has its own copy¿? it’s the same reference, it shouldn’t be a copy
pakoito
12/08/2020, 3:09 PM