Nir
07/29/2020, 8:09 PMstreetsofboston
07/29/2020, 8:12 PMNir
07/29/2020, 8:13 PMNir
07/29/2020, 8:13 PMNir
07/29/2020, 8:14 PMstreetsofboston
07/29/2020, 8:15 PMNir
07/29/2020, 8:17 PMstreetsofboston
07/29/2020, 8:18 PMclass SomeClass {
private var counter: Int = 1
fun OtherClass.updateCounter() {
counter += this.otherCounter
}
}
class OtherClass {
val otherCounter: Int = ...
}
...
with (someClass) {
otherClass.updateCounter()
}
...Nir
07/29/2020, 8:18 PMclass ImmutableList<T> internal constructor(val data: List<T>) : List<T> by data {Nir
07/29/2020, 8:18 PMfun <T> Iterable<T>.toImmutableList() = ImmutableList<T>(this.toList())Nir
07/29/2020, 8:18 PMNir
07/29/2020, 8:19 PMwith or anything like thatNir
07/29/2020, 8:19 PMNir
07/29/2020, 8:20 PMstreetsofboston
07/29/2020, 8:22 PMImmutableList and the toImmutableList in a separate module will allow this (internal scope), but if the client of your code is in the same module, you’re out of luck….Nir
07/29/2020, 8:23 PMNir
07/29/2020, 8:23 PMNir
07/29/2020, 8:23 PMstreetsofboston
07/29/2020, 8:23 PMpackage private would work. There are a few issues/requests out there to add that scope for Kotlin (like in Java).Nir
07/29/2020, 8:24 PMNir
07/29/2020, 8:25 PMError:(7, 11) Kotlin: 'public' function exposes its 'private' parameter type KeyNir
07/29/2020, 8:25 PMNir
07/29/2020, 8:25 PMMarc Knaup
07/29/2020, 10:17 PMsealed class for that 🙂Nir
07/29/2020, 11:23 PMNir
07/29/2020, 11:23 PMNir
07/29/2020, 11:23 PMMarc Knaup
07/29/2020, 11:26 PMprivate is “same file only”.Nir
07/29/2020, 11:33 PMNir
07/29/2020, 11:34 PMMarc Knaup
07/29/2020, 11:58 PMfileprivate in Swift would be nice sometimes 🙂Nir
07/29/2020, 11:59 PMNir
07/29/2020, 11:59 PMMarc Knaup
07/30/2020, 12:01 AMsealed class trick you could also make keys. But it’s a weird workaround imo 😅Nir
07/30/2020, 12:04 AM