{"action":"created","comment":{"url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/comments/49017685","id":49017685,"diff_hunk":"@@ -0,0 +1,623 @@\n+# The Official raywenderlich.com Swift Style Guide.\n+\n+This style guide is different from others you may see, because the focus is centered on readability for print and the web. We created this style guide to keep the code in our books, tutorials, and starter kits nice and consistent — even though we have many different authors working on the books.\n+\n+Our overarching goals are conciseness, readability, and simplicity.\n+\n+Writing Objective-C? Check out our [Objective-C Style Guide](https://github.com/raywenderlich/objective-c-style-guide) too.\n+\n+## Table of Contents\n+\n+* [Naming](#naming)\n+  * [Prose](#prose)\n+  * [Class Prefixes](#class-prefixes)\n+* [Spacing](#spacing)\n+* [Comments](#comments)\n+* [Classes and Structures](#classes-and-structures)\n+  * [Use of Self](#use-of-self)\n+  * [Protocol Conformance](#protocol-conformance)\n+  * [Computed Properties](#computed-properties)\n+* [Function Declarations](#function-declarations)\n+* [Closure Expressions](#closure-expressions)\n+* [Types](#types)\n+  * [Constants](#constants)\n+  * [Optionals](#optionals)\n+  * [Struct Initializers](#struct-initializers)\n+  * [Type Inference](#type-inference)\n+  * [Syntactic Sugar](#syntactic-sugar)\n+* [Control Flow](#control-flow)\n+* [Semicolons](#semicolons)\n+* [Language](#language)\n+* [Copyright Statement](#copyright-statement)\n+* [Smiley Face](#smiley-face)\n+* [Credits](#credits)\n+\n+\n+## Naming\n+\n+Use descriptive names with camel case for classes, methods, variables, etc. Class names should be capitalized, while method names and variables should start with a lower case letter.\n+\n+**Preferred:**\n+\n+```swift\n+private let maximumWidgetCount = 100\n+\n+class WidgetContainer {\n+  var widgetButton: UIButton\n+  let widgetHeightPercentage = 0.85\n+}\n+```\n+\n+**Not Preferred:**\n+\n+```swift\n+let MAX_WIDGET_COUNT = 100\n+\n+class app_widgetContainer {\n+  var wBut: UIButton\n+  let wHeightPct = 0.85\n+}\n+```\n+\n+For functions and init methods, prefer named parameters for all arguments unless the context is very clear. Include external parameter names if it makes function calls more readable.\n+\n+```swift\n+func dateFromString(dateString: String) -> NSDate\n+func convertPointAt(column column: Int, row: Int) -> CGPoint\n+func timedAction(afterDelay delay: NSTimeInterval, perform action: SKAction) -> SKAction!\n+\n+// would be called like this:\n+dateFromString(\"2014-03-14\")\n+convertPointAt(column: 42, row: 13)\n+timedAction(afterDelay: 1.0, perform: someOtherAction)\n+```\n+\n+For methods, follow the standard Apple convention of referring to the first parameter in the method name:\n+\n+```swift\n+class Counter {\n+  func combineWith(otherCounter: Counter, options: Dictionary?) { ... }\n+  func incrementBy(amount: Int) { ... }\n+}\n+```\n+\n+### Enumerations\n+\n+Use UpperCamelCase for enumeration values:\n+\n+```swift\n+enum Shape {\n+  case Rectangle\n+  case Square\n+  case Triangle\n+  case Circle\n+}\n+```\n+\n+### Prose\n+\n+When referring to functions in prose (tutorials, books, comments) include the required parameter names from the caller's perspective or `_` for unnamed parameters.\n+\n+> Call `convertPointAt(column:row:)` from your own `init` implementation.\n+>\n+> If you call `dateFromString(_:)` make sure that you provide a string with the format \"yyyy-MM-dd\".\n+>\n+> If you call `timedAction(afterDelay:perform:)` from `viewDidLoad()` remember to provide an adjusted delay value and an action to perform.\n+>\n+> You shouldn't call the data source method `tableView(_:cellForRowAtIndexPath:)` directly.\n+\n+When in doubt, look at how Xcode lists the method in the jump bar – our style here matches that.\n+\n+![Methods in Xcode jump bar](screens/xcode-jump-bar.png)\n+\n+### Class Prefixes\n+\n+Swift types are automatically namespaced by the module that contains them and you should not add a class prefix. If two names from different modules collide you can disambiguate by prefixing the type name with the module name.\n+\n+```swift\n+import SomeModule\n+\n+let myClass = MyModule.UsefulClass()\n+```\n+\n+\n+## Spacing\n+\n+* Indent using 2 spaces rather than tabs to conserve space and help prevent line wrapping. Be sure to set this preference in Xcode as shown below:\n+\n+  ![Xcode indent settings](screens/indentation.png)\n+\n+* Method braces and other braces (`if`/`else`/`switch`/`while` etc.) always open on the same line as the statement but close on a new line.\n+* Tip: You can re-indent by selecting some code (or ⌘A to select all) and then Control-I (or Editor\\Structure\\Re-Indent in the menu). Some of the Xcode template code will have 4-space tabs hard coded, so this is a good way to fix that.\n+\n+**Preferred:**\n+```swift\n+if user.isHappy {\n+  // Do something\n+} else {","path":"README.mdown","position":137,"original_position":137,"commit_id":"6aec9b0a80c58c5d19769779523f497ab5ce57b3","original_commit_id":"ddf7153f10ad404f089139e319c755f82e0fedde","user":{"login":"gdaniele","id":926104,"avatar_url":"https://avatars.githubusercontent.com/u/926104?v=3","gravatar_id":"","url":"https://api.github.com/users/gdaniele","html_url":"https://github.com/gdaniele","followers_url":"https://api.github.com/users/gdaniele/followers","following_url":"https://api.github.com/users/gdaniele/following{/other_user}","gists_url":"https://api.github.com/users/gdaniele/gists{/gist_id}","starred_url":"https://api.github.com/users/gdaniele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdaniele/subscriptions","organizations_url":"https://api.github.com/users/gdaniele/orgs","repos_url":"https://api.github.com/users/gdaniele/repos","events_url":"https://api.github.com/users/gdaniele/events{/privacy}","received_events_url":"https://api.github.com/users/gdaniele/received_events","type":"User","site_admin":false},"body":"So, I actually prefer the style proposed in this style guide but I'm pretty  ¯\\_(ツ)_/¯\r\n\r\n```Swift\r\nif user.isHappy {\r\n  // Do something\r\n} else {\r\n\r\n}\r\n```","created_at":"2016-01-06T22:18:40Z","updated_at":"2016-01-06T22:18:40Z","html_url":"https://github.com/quizlet/swift-style-guide/pull/2#discussion_r49017685","pull_request_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/comments/49017685"},"html":{"href":"https://github.com/quizlet/swift-style-guide/pull/2#discussion_r49017685"},"pull_request":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2","id":55269666,"html_url":"https://github.com/quizlet/swift-style-guide/pull/2","diff_url":"https://github.com/quizlet/swift-style-guide/pull/2.diff","patch_url":"https://github.com/quizlet/swift-style-guide/pull/2.patch","issue_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/2","number":2,"state":"open","locked":false,"title":"Adds RayWenderlich Style Guide as Quizlet Style Guide Starting Point","user":{"login":"gdaniele","id":926104,"avatar_url":"https://avatars.githubusercontent.com/u/926104?v=3","gravatar_id":"","url":"https://api.github.com/users/gdaniele","html_url":"https://github.com/gdaniele","followers_url":"https://api.github.com/users/gdaniele/followers","following_url":"https://api.github.com/users/gdaniele/following{/other_user}","gists_url":"https://api.github.com/users/gdaniele/gists{/gist_id}","starred_url":"https://api.github.com/users/gdaniele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdaniele/subscriptions","organizations_url":"https://api.github.com/users/gdaniele/orgs","repos_url":"https://api.github.com/users/gdaniele/repos","events_url":"https://api.github.com/users/gdaniele/events{/privacy}","received_events_url":"https://api.github.com/users/gdaniele/received_events","type":"User","site_admin":false},"body":"#### Quizlet Swift Style Guide :art: \r\n\r\n- [ ] Review/Discussion/Debate @shanem \r\n- [ ] Review/Discussion/Debate @jaclync\r\n- [ ] Review/Discussion/Debate @fallenpanda1 \r\n\r\nThe goal of this PR is to create a living document of Quizlet Swift styling best practices from our own experience and preferences, as well as from outside resources. \r\n\r\nThis PR includes the [Ray Wenderlich Swift Style Guide](https://github.com/raywenderlich/swift-style-guide) as a starting point. This repo is also forked from the that style guide as well. Obviously, since we're talking about style here, there are things in the RW style guide that should be discussed and challenged in this PR. \r\n\r\n#### Moving forward\r\n\r\nI thought we could consider adding PRs to this repo for Swift style change proposals in the future. One thing we'd want to do here is make sure that _each team member_ signs off before merging PRs to this repository (including this one!).\r\n\r\n#### Linting\r\n\r\nIt would be nice (but not necessary) to use something like [SwiftLint](https://github.com/realm/SwiftLint) to make these styling considerations more automated in the future.\r\n\r\n#### Other resources :microscope: \r\n\r\n* [GitHub Swift Style Guide](https://github.com/github/swift-style-guide)","created_at":"2016-01-06T21:49:39Z","updated_at":"2016-01-06T22:18:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4713d4a767502871aef99dd57d29fb090d27a1a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2/commits","review_comments_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2/comments","review_comment_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/2/comments","statuses_url":"https://api.github.com/repos/quizlet/swift-style-guide/statuses/6aec9b0a80c58c5d19769779523f497ab5ce57b3","head":{"label":"quizlet:giancarlo/addRWReadme","ref":"giancarlo/addRWReadme","sha":"6aec9b0a80c58c5d19769779523f497ab5ce57b3","user":{"login":"quizlet","id":616547,"avatar_url":"https://avatars.githubusercontent.com/u/616547?v=3","gravatar_id":"","url":"https://api.github.com/users/quizlet","html_url":"https://github.com/quizlet","followers_url":"https://api.github.com/users/quizlet/followers","following_url":"https://api.github.com/users/quizlet/following{/other_user}","gists_url":"https://api.github.com/users/quizlet/gists{/gist_id}","starred_url":"https://api.github.com/users/quizlet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quizlet/subscriptions","organizations_url":"https://api.github.com/users/quizlet/orgs","repos_url":"https://api.github.com/users/quizlet/repos","events_url":"https://api.github.com/users/quizlet/events{/privacy}","received_events_url":"https://api.github.com/users/quizlet/received_events","type":"Organization","site_admin":false},"repo":{"id":49162701,"name":"swift-style-guide","full_name":"quizlet/swift-style-guide","owner":{"login":"quizlet","id":616547,"avatar_url":"https://avatars.githubusercontent.com/u/616547?v=3","gravatar_id":"","url":"https://api.github.com/users/quizlet","html_url":"https://github.com/quizlet","followers_url":"https://api.github.com/users/quizlet/followers","following_url":"https://api.github.com/users/quizlet/following{/other_user}","gists_url":"https://api.github.com/users/quizlet/gists{/gist_id}","starred_url":"https://api.github.com/users/quizlet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quizlet/subscriptions","organizations_url":"https://api.github.com/users/quizlet/orgs","repos_url":"https://api.github.com/users/quizlet/repos","events_url":"https://api.github.com/users/quizlet/events{/privacy}","received_events_url":"https://api.github.com/users/quizlet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quizlet/swift-style-guide","description":"The official Swift style guide for raywenderlich.com.","fork":true,"url":"https://api.github.com/repos/quizlet/swift-style-guide","forks_url":"https://api.github.com/repos/quizlet/swift-style-guide/forks","keys_url":"https://api.github.com/repos/quizlet/swift-style-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quizlet/swift-style-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quizlet/swift-style-guide/teams","hooks_url":"https://api.github.com/repos/quizlet/swift-style-guide/hooks","issue_events_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/events{/number}","events_url":"https://api.github.com/repos/quizlet/swift-style-guide/events","assignees_url":"https://api.github.com/repos/quizlet/swift-style-guide/assignees{/user}","branches_url":"https://api.github.com/repos/quizlet/swift-style-guide/branches{/branch}","tags_url":"https://api.github.com/repos/quizlet/swift-style-guide/tags","blobs_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quizlet/swift-style-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/quizlet/swift-style-guide/languages","stargazers_url":"https://api.github.com/repos/quizlet/swift-style-guide/stargazers","contributors_url":"https://api.github.com/repos/quizlet/swift-style-guide/contributors","subscribers_url":"https://api.github.com/repos/quizlet/swift-style-guide/subscribers","subscription_url":"https://api.github.com/repos/quizlet/swift-style-guide/subscription","commits_url":"https://api.github.com/repos/quizlet/swift-style-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/quizlet/swift-style-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/quizlet/swift-style-guide/contents/{+path}","compare_url":"https://api.github.com/repos/quizlet/swift-style-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quizlet/swift-style-guide/merges","archive_url":"https://api.github.com/repos/quizlet/swift-style-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quizlet/swift-style-guide/downloads","issues_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues{/number}","pulls_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/quizlet/swift-style-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/quizlet/swift-style-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quizlet/swift-style-guide/labels{/name}","releases_url":"https://api.github.com/repos/quizlet/swift-style-guide/releases{/id}","created_at":"2016-01-06T21:26:34Z","updated_at":"2016-01-06T18:28:48Z","pushed_at":"2016-01-06T22:13:05Z","git_url":"git://github.com/quizlet/swift-style-guide.git","ssh_url":"git@github.com:quizlet/swift-style-guide.git","clone_url":"https://github.com/quizlet/swift-style-guide.git","svn_url":"https://github.com/quizlet/swift-style-guide","homepage":null,"size":182,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"quizlet:master","ref":"master","sha":"453a22b6b28ae9a69512c6c14f0ec8831be54e7e","user":{"login":"quizlet","id":616547,"avatar_url":"https://avatars.githubusercontent.com/u/616547?v=3","gravatar_id":"","url":"https://api.github.com/users/quizlet","html_url":"https://github.com/quizlet","followers_url":"https://api.github.com/users/quizlet/followers","following_url":"https://api.github.com/users/quizlet/following{/other_user}","gists_url":"https://api.github.com/users/quizlet/gists{/gist_id}","starred_url":"https://api.github.com/users/quizlet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quizlet/subscriptions","organizations_url":"https://api.github.com/users/quizlet/orgs","repos_url":"https://api.github.com/users/quizlet/repos","events_url":"https://api.github.com/users/quizlet/events{/privacy}","received_events_url":"https://api.github.com/users/quizlet/received_events","type":"Organization","site_admin":false},"repo":{"id":49162701,"name":"swift-style-guide","full_name":"quizlet/swift-style-guide","owner":{"login":"quizlet","id":616547,"avatar_url":"https://avatars.githubusercontent.com/u/616547?v=3","gravatar_id":"","url":"https://api.github.com/users/quizlet","html_url":"https://github.com/quizlet","followers_url":"https://api.github.com/users/quizlet/followers","following_url":"https://api.github.com/users/quizlet/following{/other_user}","gists_url":"https://api.github.com/users/quizlet/gists{/gist_id}","starred_url":"https://api.github.com/users/quizlet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quizlet/subscriptions","organizations_url":"https://api.github.com/users/quizlet/orgs","repos_url":"https://api.github.com/users/quizlet/repos","events_url":"https://api.github.com/users/quizlet/events{/privacy}","received_events_url":"https://api.github.com/users/quizlet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quizlet/swift-style-guide","description":"The official Swift style guide for raywenderlich.com.","fork":true,"url":"https://api.github.com/repos/quizlet/swift-style-guide","forks_url":"https://api.github.com/repos/quizlet/swift-style-guide/forks","keys_url":"https://api.github.com/repos/quizlet/swift-style-guide/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quizlet/swift-style-guide/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quizlet/swift-style-guide/teams","hooks_url":"https://api.github.com/repos/quizlet/swift-style-guide/hooks","issue_events_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/events{/number}","events_url":"https://api.github.com/repos/quizlet/swift-style-guide/events","assignees_url":"https://api.github.com/repos/quizlet/swift-style-guide/assignees{/user}","branches_url":"https://api.github.com/repos/quizlet/swift-style-guide/branches{/branch}","tags_url":"https://api.github.com/repos/quizlet/swift-style-guide/tags","blobs_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/refs{/sha}","trees_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quizlet/swift-style-guide/statuses/{sha}","languages_url":"https://api.github.com/repos/quizlet/swift-style-guide/languages","stargazers_url":"https://api.github.com/repos/quizlet/swift-style-guide/stargazers","contributors_url":"https://api.github.com/repos/quizlet/swift-style-guide/contributors","subscribers_url":"https://api.github.com/repos/quizlet/swift-style-guide/subscribers","subscription_url":"https://api.github.com/repos/quizlet/swift-style-guide/subscription","commits_url":"https://api.github.com/repos/quizlet/swift-style-guide/commits{/sha}","git_commits_url":"https://api.github.com/repos/quizlet/swift-style-guide/git/commits{/sha}","comments_url":"https://api.github.com/repos/quizlet/swift-style-guide/comments{/number}","issue_comment_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues/comments{/number}","contents_url":"https://api.github.com/repos/quizlet/swift-style-guide/contents/{+path}","compare_url":"https://api.github.com/repos/quizlet/swift-style-guide/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quizlet/swift-style-guide/merges","archive_url":"https://api.github.com/repos/quizlet/swift-style-guide/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quizlet/swift-style-guide/downloads","issues_url":"https://api.github.com/repos/quizlet/swift-style-guide/issues{/number}","pulls_url":"https://api.github.com/repos/quizlet/swift-style-guide/pulls{/number}","milestones_url":"https://api.github.com/repos/quizlet/swift-style-guide/milestones{/number}","notifications_url":"https://api.github.com/repos/quizlet/swift-style-guide/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quizlet/swift-style-guide/labels{/name}","releases_url":"https://api.github.com/repos/quizlet/swift-style-guide/releases{/id}","created_at":"2016-01-06T21:26:34Z","updated_at":"2016-01-06T18:28:48Z","pushed_at":"2016-01-06T22:13:05Z","git_url":"git://github.com/quizlet/swift-style-guide.git","ssh_url":"git@github.com:quizlet/swift-style-guide.git","clone_url":"https://github.com/quizlet/swift-style-guide.git","svn_url":"https://github.com/quizlet/swift-style-guide","homepage":null,"size":182,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2"},"html":{"href":"https://github.com/quizlet/swift-style-guide/pull/2"},"issue":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/issues/2"},"comments":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/quizlet/swift-style-guide/statuses/6aec9b0a80c58c5d19769779523f497ab5ce57b3"}}}}