In swift I can create a method like -
#1
func baseURL() -> String {
#if DEBUG
return "https://debug.myserver.url.com"
#else
return "https://production.myserver.url.com"
#endif
}
I can also write it in this way -
#2
var baseURL:String {
#if DEBUG
return "https://debug.myserver.url.com"
#else
return "https://production.myserver.url.com"
#endif
}
The requirement of declaring a get only property is met by both methods. Personally I find the second method better cos of readablility.
I know its not too much of a difference, but I'd still like to know which one is better? Does either method have any advantage over the other?