[struct] set access modifier
igotfr opened this issue · 3 comments
igotfr commented
struct Sct {
set:
n int
}
s := Sct{n: 5}
s.n = 7 // ok
println(s.n) // error
igotfr commented
related:
vlang/v#13727
spytheman commented
Why?
igotfr commented
@spytheman a property that can't be accessed directly, only setted, but it's useful for calculations in methods with visible return (computed), similar to private, but of course, no inheritance
I know abstract motivation but I don't remember any real-world scenarios (I guess the best example is a password)
In V, specifically for properties we have:
mut | get | set |
default | get |
with set, would be:
set | set |