Hi all - I’m trying to create a Kotlin equivalent ...
# announcements
d
Hi all - I’m trying to create a Kotlin equivalent of this Java code:
Copy code
public class Example {
    private String value = "";

    public String getValue() {
        return value;
    }
}
For mocking reasons, I need the
getValue()
method to be open, but I want to keep any setter private. Here’s what I tried in Kotlin:
Copy code
open class Example {
    open var value: String = ""
        private set
}
But, that won’t compile:
Private setters are not allowed for open properties
Is there any way to achieve this without using backing fields?