I want to overload the operator for my struct but I get the message "static member 'rating' cannot be used on instance of type 'GlobalSettings'".
I already read couple answers to this error but the solutions there don't help me at all. How can I solve this problem?
struct GlobalSettings{
static var rating = false
}
func ==(l: GlobalSettings, r: GlobalSettings) -> Bool {
if l.rating == r.rating {
return true
}else{
return false
}
}
It is an obvious error. Static member can not be accessed with Instance variables like l
and r
.
Static members must be accessed through the type (class
/struct
/enum
) name like:
GlobalSettings.rating