Re: [swift-users] lazy initialisation

2016-07-04 Thread Zhao Xin via swift-users
No, it is not a bug. For a closure, you have to call self explicitly unless the closure is mark as @noescape. Also, in this situation, self is not unowned, as the closure is not stored, it ran and released. Below, is a situation that you need use unowned self. Here the closure is stored in

Re: [swift-users] lazy initialisation

2016-07-04 Thread Karl via swift-users
> On 4 Jul 2016, at 21:12, Mark Dalrymple via swift-users > wrote: > > Here's the one I started with: > >lazy var c:Int = {return a*b}() > > and ended up with: > > lazy var c:Int = {return self.a * self.b}() > > It's in a closure, so need to explicitly

Re: [swift-users] lazy initialisation

2016-07-04 Thread J.E. Schotsman via swift-users
> On 04 Jul 2016, at 19:21, Zhao Xin wrote: > > You'd better sharing some of you code here first. For example, consider this: class TestStruct1 { let a = 10 let b = 20 let c:Int = {return self.a*self.b}() } Of course this is a

Re: [swift-users] lazy initialisation

2016-07-04 Thread Mark Dalrymple via swift-users
This works for me class Blorg: NSObject, URLSessionDelegate { var config: URLSessionConfiguration lazy var session: URLSession = { print("howdy") return URLSession(configuration: self.config, delegate: self, delegateQueue: nil) }() override init() {

[swift-users] Why unary ++ operator has been deprecated?

2016-07-04 Thread Martin Delille via swift-users
Everything is in the title. ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Why can't Swift instance methods call class methods without qualification?

2016-07-04 Thread Rick Mann via swift-users
> Karen Stone wrote: >> I believe there’s real value in being explicit about referencing class >> members. It helps both the reader of the code and it makes writing code >> with typical IDE conveniences like code completion less cluttered and more >> informative. Unfamiliar class methods