Skip to content

Instantly share code, notes, and snippets.

@alexbaramilis
Last active December 5, 2018 19:32
Show Gist options
  • Save alexbaramilis/9782946ce7c90857fa970f8872fcdb39 to your computer and use it in GitHub Desktop.
Save alexbaramilis/9782946ce7c90857fa970f8872fcdb39 to your computer and use it in GitHub Desktop.
Namespacing with enums 1
struct API1 {
static let BaseURL = "api.airvisual.com/v2/nearest_city?lat={{LATITUDE}}&lon={{LONGITUDE}}&key={{YOUR_API_KEY}}"
static let Key = "your_api_key"
}
enum API2 {
static let BaseURL = "api.airvisual.com/v2/nearest_city?lat={{LATITUDE}}&lon={{LONGITUDE}}&key={{YOUR_API_KEY}}"
static let Key = "your_api_key"
}
let baseURL1 = API1.BaseURL
let baseURL2 = API2.BaseURL
let api1 = API1()
let api2 = API2() // Compiler Error: 'API2' cannot be constructed because it has no accessible initializers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment