It turns out that within a Dictionary extension, the subscript is quite useless since it says Ambiguous reference to member 'subscript'
. It seems I'll either have to do what Swift does in its subscript(Key)
or call a function. Any ideas?
For example,
public extension Dictionary {
public func bool(_ key: String) -> Bool? {
return self[key] as? Bool
}
}
won't work, since the subscript is said to be ambiguous.
ADDED My misunderstanding came from the fact that I assumed that Key
is an AssociatedType
instead of a generic parameter.