When using @dynamicMemberLookup in swift, subscript cannot declare a "throws".
subscript(dynamicMember member: String) -> Any
This is OK.
subscript(dynamicMember member: String) throws -> Any
This will give a compile error.
When using @dynamicMemberLookup in swift, subscript cannot declare a "throws".
subscript(dynamicMember member: String) -> Any
This is OK.
subscript(dynamicMember member: String) throws -> Any
This will give a compile error.
Copyright © 2021 Jogjafile Inc.
Using
throwsinsubscriptis not supported by the language right now. However you can use some tricks to avoid that, meanwhile, keep the feature ofthrows:Just declare the subscription return an block, then add a
()behind the function to execute the real function. So you could code like this: