[swift-users] Lazy expression is ambiguous?
Quinn "The Eskimo!"
eskimo1 at apple.com
Mon Sep 12 02:02:41 CDT 2016
On 12 Sep 2016, at 06:40, Jacob Bandes-Storch via swift-users <swift-users at swift.org> wrote:
> I'd recommend filing a bug at bugs.swift.org.
Also, you can work around this by adding a type.
lazy var myQ: DispatchQueue = DispatchQueue(label: "Op", attributes: .concurrent)
Also, with regards this specific example, be aware that lazy properties aren’t guaranteed to be initialised only once. To quote “The Swift Programming Language”:
If a property marked with the `lazy` modified is accessed by multiple
threads simultaneously and the property has not yet been initialized,
there is no guarantee that the property will be initialized only once.
I’m struggling to think of a case where that limitation is acceptable in the context of a dispatch queue (-:
Share and Enjoy
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
More information about the swift-users