I've stumbled upon some code where the variable declarations use return to assign the variable value like below:
var method: HTTPMethod { return .Post}
Is the line above the same as below?
var method: HTTPMethod = .Post
The two lines are not so similar.
The first line declares a computed property without the setter. This means that the value is constant.
The second declaration is a simple property declaration with the value initialised to .Post. This means that the property can be changed later on.
The first line is more similar to the following line than to your second line:
let method: HTTPMethod = .Post
Since the above also declares a constant property.
Then what's the difference between a let constant property and a computed property without a setter and returns a constant value? The main difference is that a computed property can be put into extensions while let constants cannot.
No both are different
This one is get-only property
var method: HTTPMethod { return .Post}
and second one is mutable object where you can assign different value.
var method: HTTPMethod = .Post