I have checking out some code and I came across code that is marked as open
for a variable and it is a stored property. What kind of use does open
have over public
in this case? This is some made up code:
open class God {
open var hasSuperPowers = true
}
class HalfGod: God {
override var hasSuperPowers = false
}
This does not compile: Cannot override with a stored property 'hasSuperPowers'
. This is because the variable is stored.
My question is therefore: What difference does it make when marking my stored property either open
or public
? Can I do something with an open
stored property, which I can not do with a public
stored property?
I would expect xCode
would give me warning that marking hasSuperPowers
as open
would have no effect and would falsely imply to other people that they can override this variable. Ofcourse, this only applies when someone can confirm me that open
or public
does not make any difference.
Edit: I got now three people showing me the difference between open and var. Does my question even get read? Again:
What difference does it make when marking my stored property either open
or public
? Again: STORED PROPERTY