https://kotlinlang.org logo
b

benleggiero

02/13/2017, 2:58 PM
I prefer this syntax:
Copy code
public private(set) var a
m

miha-x64

02/13/2017, 2:59 PM
and if you want to override a setter?
b

benleggiero

02/13/2017, 3:00 PM
It'll work the same:
Copy code
public private(set) var a
    get() = ...
    set(newValue) = ...
m

miha-x64

02/13/2017, 3:01 PM
Why you don’t like existing syntax? It’s clear when private stands on a new line:
Copy code
public var a ...
    private set
b

benleggiero

02/13/2017, 3:02 PM
Just
set(newValue)
would only be callable inside
private
scope, while all other scopes just see an immutable `val`and its
get()
That might work too!
m

miha-x64

02/13/2017, 3:02 PM
That already works 🙂
b

benleggiero

02/13/2017, 3:02 PM
Just voicing my opinions :)
2 Views