groostav
05/02/2024, 2:53 AMclass MyImmutableType(val property: Array<out AnotherImmutableType>)
Im guessing that a java caller of the same file is only going to see AnotherImmutableType[]
So... its not a very strong gaurentee; but if you're pure kotlin... is it strong enough?CLOVIS
05/02/2024, 2:02 PMgroostav
05/02/2024, 5:22 PMArray<out String>
means you cant call set. I'm wondering if anyone uses this as a pseudo immutable type as a result.CLOVIS
05/02/2024, 8:03 PMList
because of clear
, but it does seem to work on arrays 🤔
I still would just use a List
, though. I think the intent is clearer.groostav
05/22/2024, 1:48 AMJVMName
to make an accessor inaccessible from java:
class Thingy(
private val dogs: Array<out Dog>
){
@JvmName("\$accessDogs") fun accessDogs() = dogs
}
this will mean java callers cannot call accessDogs
as they cant denote the function name, but kotlin will have no trouble... though I'm guessing the kotlin source code name thus gets embedded as an annotation on the result?