{"action":"created","issue":{"url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/88","labels_url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/88/comments","events_url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/88/events","html_url":"https://github.com/raywenderlich/swift-style-guide/issues/88","id":68698569,"number":88,"title":"Lazy initializing pattern","user":{"login":"rwenderlich","id":438377,"avatar_url":"https://avatars.githubusercontent.com/u/438377?v=3","gravatar_id":"","url":"https://api.github.com/users/rwenderlich","html_url":"https://github.com/rwenderlich","followers_url":"https://api.github.com/users/rwenderlich/followers","following_url":"https://api.github.com/users/rwenderlich/following{/other_user}","gists_url":"https://api.github.com/users/rwenderlich/gists{/gist_id}","starred_url":"https://api.github.com/users/rwenderlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwenderlich/subscriptions","organizations_url":"https://api.github.com/users/rwenderlich/orgs","repos_url":"https://api.github.com/users/rwenderlich/repos","events_url":"https://api.github.com/users/rwenderlich/events{/privacy}","received_events_url":"https://api.github.com/users/rwenderlich/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-15T14:34:51Z","updated_at":"2015-04-16T18:54:04Z","closed_at":null,"body":"A lot of us in tutorials these days are using patterns like this to initialize variables:\r\n\r\n```\r\nlazy var locationManager: CLLocationManager = {\r\n    let manager = CLLocationManager()\r\n    manager.desiredAccuracy = kCLLocationAccuracyBest\r\n    manager.delegate = self\r\n    manager.requestAlwaysAuthorization()\r\n    return manager\r\n  }()\r\n```\r\n\r\nI've seen this for setting up controls like `UILabels` and such too. This has the advantage of keeping the initialization code in one handy place.\r\n\r\nI thought I'd start a discussion to see if this is a pattern we want to encourage in the style guide?"},"comment":{"url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/comments/93814365","html_url":"https://github.com/raywenderlich/swift-style-guide/issues/88#issuecomment-93814365","issue_url":"https://api.github.com/repos/raywenderlich/swift-style-guide/issues/88","id":93814365,"user":{"login":"moayes","id":1355115,"avatar_url":"https://avatars.githubusercontent.com/u/1355115?v=3","gravatar_id":"","url":"https://api.github.com/users/moayes","html_url":"https://github.com/moayes","followers_url":"https://api.github.com/users/moayes/followers","following_url":"https://api.github.com/users/moayes/following{/other_user}","gists_url":"https://api.github.com/users/moayes/gists{/gist_id}","starred_url":"https://api.github.com/users/moayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moayes/subscriptions","organizations_url":"https://api.github.com/users/moayes/orgs","repos_url":"https://api.github.com/users/moayes/repos","events_url":"https://api.github.com/users/moayes/events{/privacy}","received_events_url":"https://api.github.com/users/moayes/received_events","type":"User","site_admin":false},"created_at":"2015-04-16T18:54:04Z","updated_at":"2015-04-16T18:54:04Z","body":"I like it too. 👍"}}