Swift: what is the difference between properties and functions?
Swift: what is the difference between properties and functions?
- Subject: Swift: what is the difference between properties and functions?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 01 Aug 2014 15:49:09 +0700
To be more exact:
What is the difference between a read-only property and a function with no arguments returning a value?
Like:
class Wether
{
var temperature: String
{
get
{
return "37.2" // or return result of some computation
}
}
func forecast() -> String
{
return "A thick coat of wool" // or return result of some deliberation
}
}
let w = Wether()
println("The temperature is \(w.temperature)°C and the forecast is: \"\(w.forecast())\"")
Is one more efficient than the other? Or stylistically better?
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden