Nir
07/05/2019, 2:34 PMstreetsofboston
07/05/2019, 2:37 PMopen.Nir
07/05/2019, 2:39 PMUser and a MutableUser that inherits from User?Nir
07/05/2019, 2:40 PMNir
07/05/2019, 2:47 PMNir
07/05/2019, 2:47 PMx = x.copy(age=5) is just really verbose compared to x.age=5.Nir
07/05/2019, 2:47 PMgildor
07/05/2019, 3:10 PMgildor
07/05/2019, 3:10 PMgildor
07/05/2019, 3:11 PMstreetsofboston
07/05/2019, 3:14 PMNir
07/05/2019, 3:18 PMNir
07/05/2019, 3:19 PMx = x.copy(age=5) is still very verboseNir
07/05/2019, 3:19 PMNir
07/05/2019, 3:20 PMList, and you can call them with your MutableList, which is fantastic.Nir
07/05/2019, 3:20 PMNir
07/05/2019, 3:20 PMstreetsofboston
07/05/2019, 3:20 PMdata class implements. However, the copy function won’t be derivable from that interface….Nir
07/05/2019, 3:20 PMconst as a modifier, which is really fantastic.streetsofboston
07/05/2019, 3:21 PMconst. I like that, too. I wish, though, that const were the default and another keyword like mutable would have been used instead.Nir
07/05/2019, 3:21 PMNir
07/05/2019, 3:21 PMNir
07/05/2019, 3:22 PMvoid foo(const string&) is guaranteed (well, almost) not to modify its inputNir
07/05/2019, 3:22 PMstringNir
07/05/2019, 3:23 PMList and MutableList essentially emulates this with inheritance.streetsofboston
07/05/2019, 3:24 PMMutableList being a sub-interface of List. ImmutableList and MutableList should not have a parent-child hierarchy. If I have a List, it could be implemented by a mutable list, which means I cannot assume the List i have is actual immutable..streetsofboston
07/05/2019, 3:26 PMNir
07/05/2019, 3:29 PMNir
07/05/2019, 3:29 PMList is immutable (IMHO)Nir
07/05/2019, 3:29 PMNir
07/05/2019, 3:30 PMconst& is actually immutable.Nir
07/05/2019, 3:30 PMimmutable keyword but it's been a pretty mixed bag by most accountsstreetsofboston
07/05/2019, 3:31 PMNir
07/05/2019, 3:33 PMstreetsofboston
07/05/2019, 3:50 PMinterface MyData {
val id: Int
val name: String
}
data class MutableMyData(
override var id: Int,
override var name: String
): MyData
Won’t get rid of the verbosity you try to avoid, though.Nir
07/05/2019, 4:00 PMNir
07/05/2019, 4:00 PMNir
07/05/2019, 4:00 PMNir
07/05/2019, 4:01 PMNir
07/05/2019, 4:01 PMNir
07/05/2019, 4:01 PMstreetsofboston
07/05/2019, 4:03 PMcopy function is the biggest trip-up. I wish there was a data interface of some sortNir
07/05/2019, 4:03 PMNir
07/05/2019, 4:03 PMNir
07/05/2019, 4:04 PMNir
07/05/2019, 4:04 PM