public enum TutorialType : String {
case tutorial1
case tutorial2
}
extension TutorialType {
public var displayed: Bool {
get { return UserDefaults.standard.bool(forKey: self.rawValue) }
set { UserDefaults.standard.set(newValue, forKey: self.rawValue) }
}
}
func showTutorial(_ type: TutorialType) {
// 1. show the tutorial
// ...
// 2. set displayed to true
type.displayed = true //cannot assign to property: 'type' is a 'let' constant
}
Hi:
As above, I have added a non-mutating compute attribute 'displayed' to TutorialType.
But when I use it in 'showTutorial(_:)' , the compiler will requires to me change type
to a mutable variable. I think it should be valid to call 'type.displayed = true', is it a compiler bug? Any thoughts?