Re: Swift: what is the difference between properties and functions?
Re: Swift: what is the difference between properties and functions?
- Subject: Re: Swift: what is the difference between properties and functions?
- From: Marco S Hyman <email@hidden>
- Date: Fri, 01 Aug 2014 21:56:05 -0700
>> 2. The method is a closure, but the property isn’t. (For example, for use with Array’s ‘map’ method.)
>
> Let me paraphrase this to make sure I understand it correctly:
>
> let temp1 = w.temperature
> let forca1 = w.forecast
> println("temperature \(temp1) forecast \(forca1())") // A
>
> someFunctionWithCallback() { println("temperature \(temp1) forecast \(forca1())") }
>
> The call-back will print the same temperature as A, but might print a different forecast. Correct?
Not, I think, if forca1 is defined as above. Now if you had
used 'var' instead of 'let' then it is possible that something
other than w.forcast will be invoked.
_______________________________________________
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