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

Testing for lazy in Swift


  • Subject: Testing for lazy in Swift
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 11 Jul 2014 21:47:00 +0700

@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?

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


  • Follow-Ups:
    • Re: Testing for lazy in Swift
      • From: Chris Lattner <email@hidden>
  • Prev by Date: Re: performSelector in Swift
  • Next by Date: Re: Testing for lazy in Swift
  • Previous by thread: Re: performSelector in Swift
  • Next by thread: Re: Testing for lazy in Swift
  • Index(es):
    • Date
    • Thread