Testing for lazy in Swift
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