Hi guys,
My idea is simple, put an access level control token to the setter of a var

Right now, we are likely to do something like this in order to hide the setter:

fileprivate var _timestamp: Date = Date()
        
public var timestamp: Date {
        return self._timestamp
}

The idea is to do it without using another var, like this:

public var timestamp: Date {
        get { return self._timestamp }
        fileprivate set(newValue) { _timestamp = newValue }
}

In this way the setter will be available “locally” in the file but it will not 
be accessible from outside.
The only problem that I can see is how to reference the var itself? As you can 
see I used  “_timestamp” like Objective-C, but there should be another way to 
do reference it.


Cheers,

Pascal






_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to