I was browsing Alamofire sources and found a variable name that is backtick escaped in this source file
open static let `default`: SessionManager = { let configuration = URLSessionConfiguration.default configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders return SessionManager(configuration: configuration) }() However in places where variable is used there are no backticks. What's the purpose of backticks?
Removing the backticks results in the error:
Keyword 'default' cannot be used as an identifier here
According to the Swift documentation :
To use a reserved word as an identifier, put a backtick (
`)before and after it. For example,classis not a valid identifier, but`class`is valid. The backticks are not considered part of the identifier;`x`andxhave the same meaning.
In your example, default is a Swift reserved keyword, that's why backticks are needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With