• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift: what is the difference between properties and functions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Swift: what is the difference between properties and functions?
      • From: Quincey Morris <email@hidden>
References: 
 >Re: Swift: what is the difference between properties and functions? (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Swift: what is the difference between properties and functions?
  • Next by Date: Re: Swift: what is the difference between properties and functions?
  • Previous by thread: Re: Swift: what is the difference between properties and functions?
  • Next by thread: Re: Swift: what is the difference between properties and functions?
  • Index(es):
    • Date
    • Thread