06. December 2016
Case matching on optionals
If you try to switch
on an optional you will fail when matching against an already unwrapped value. This extension will match the value anyway and fail if it’s nil
.
func ~=<T: Equatable>(pattern: T?, value: T?) -> Bool {
return pattern == value
}