• 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: Testing for lazy in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing for lazy in Swift


  • Subject: Re: Testing for lazy in Swift
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 11 Jul 2014 23:27:41 +0700

On 11 Jul 2014, at 22:53, Jeremy Pereira <email@hidden> wrote:

> Have the function Talker() record the fact that it has created the instance variable in a boolean.
>
> Or if you don't want to change Talker() use a closure to set the boolean and run Talker.
>

Two very good ideas. Thanks a lot!

Kind regards

Gerriet

> On 11 Jul 2014, at 15:47, Gerriet M. Denkmann <email@hidden> wrote:
>
>>
>> @lazy var talker = Talker()	//	assume Talker takes a lot of time to initialize
>>
>> if talker == nil
>> {
>> 	println("Talker has not been created yet → so it cannot be talking → no need to stop it")}
>> 	return
>> }
>>
>> println("Talker exists → make it shut up")
>> taler.stopSpeaking()
>>
>> This obviously does not work: the test "talker == nil" creates the Talker.
>>
>> How to avoid this?


 _______________________________________________
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


References: 
 >Testing for lazy in Swift (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Testing for lazy in Swift
  • Next by Date: Re: Testing for lazy in Swift
  • Previous by thread: Testing for lazy in Swift
  • Next by thread: Re: Testing for lazy in Swift
  • Index(es):
    • Date
    • Thread