{"action":"created","comment":{"url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/comments/37283552","id":37283552,"diff_hunk":"@@ -0,0 +1,189 @@\n+Welcome! This first lesson's goals are to introduce you to the tools used to write Swift. We're also going to go over some language features that are unique to Swift, and some that you may have seen before.\n+\n+We're going to assume that you already have a copy of Xcode 7 installed. With that, let's get started!\n+\n+Open Xcode and you'll get this Welcome dialogue. \n+\n+![Xcode Welcome Screen](img/welcome.png)\n+\n+We'll be using _playgrounds_ to learn Swift. These are similar to a REPL if you've used one of those before. Click \"Get started with a playground\", give it a name, and make sure the platform is set to **OS X**. \n+\n+![Creating a new playground](img/newplayground.png)\n+\n+Awesome. Xcode will create an open the playground for you. It'll look something like this. \n+\n+![Empty Playground](img/emptyplayground.png)\n+\n+The large pane on the left is where we're going to write code. On the right is where the results of our code are displayed. You can see that there's already one line of code written for us, `var str = \"Hello, playground\"`, and the results pane says `\"Hello, playground\"`. Neat. \n+\n+Whatever you type will be run by Xcode and the results will be shown on the right. When Xcode is running code (whenever you change text), the top bar of the window will change to say \"Running\" and will show a little spinner. \n+\n+OK, let's try typing some things. \n+\n+```swift\n+var str = \"Hello, playground\"\n+\n+1 + 2\n+1/2\n+1.0/2.0\n+\n+str = \"Artsy\"\n+\n+\"Hello, Artsy\"\n+\n+\"Hello, \\(str)\"\n+```\n+\n+You can see the results in the results pane:\n+\n+![Results](img/results.png)\n+\n+These aren't necessarily surprising – integer division works like it does in most C-based languages, for example. Swift uses `\\()` to escape code within strings, similar to Ruby's `#{}`. \n+\n+Swift defines variables using `var`. While there is no type specified, the variable `str` is a `String`. Swift is a **strongly-typed language**, even though most of the time you don't explicitly annotate types. The compiler _infers_ the type of variables. So the following two lines are equivalent.\n+\n+```swift\n+var myString = \"Hello, Artsy\"\n+var myString: String = \"Hello, Artsy\"\n+```\n+\n+In Swift, `:` specifies types. Let's try breaking things – what happens if we mismatch the types?\n+\n+```swift\n+var myString: String = 1\n+```\n+\n+Swift will complain and say that `'Int' is not convertible to 'String'`. This is Swift's compile-time static type checker. It prevents bugs from happening in apps at runtime by giving you errors at compile-time. Swift's primary goal is safety. \n+\n+Let's try breaking other things. Variables in Swift are defined using `var`, but Swift has constant support, too. In fact, constants declared with `let` are preferred to variables. \n+\n+```swift\n+let constant = \"Constant\"\n+constant = \"new value\"\n+```\n+\n+Swift will error and say that it can't assign to a constant value. However, Swift is very clever about constants. It only lets you assign to them _once_, but you don't need to assign to them when you declare them. This is valid Swift:\n+\n+```swift\n+let name: String\n+\n+if someCondition {\n+    name = \"Ash\"\n+} else {\n+    name = \"Orta\"\n+}\n+\n+print(name)\n+```\n+\n+Super-cool! You can also see how Swift's `if` statements work. You _don't_ need parentheses around the condition, but you _do_ need braces around the statements. Swift doesn't have support for single-line if branches, so it's impossible to write `goto fail;` bugs. \n+\n+`for` loops follow a similar convention:\n+\n+```swift\n+for var i = 0; i < 10; i++ {\n+    print(\"Hi: \\(i)\")\n+}\n+```\n+\n+But if we look at the results pane, we see it only says \"(10 times)\" – that's because it's unable to show the output from lines of code that get executed more than once. \n+\n+![Results for lines run multiple times](img/tentimes.png)\n+\n+To see these results, we'll open the debug area. Click the small, upward-facing triangle in the lower-left corner of the window.\n+\n+![Debug area](img/multipleresults.png)\n+\n+Swift also has some other really neat constructs, like _ranges_. The `for` loop from earlier could be rewritten as the following:\n+\n+```swift\n+for i in 0..<10 {\n+    print(\"Hi: \\(i)\")\n+}\n+```\n+\n+This does the same thing, but has a crucial difference: `i` is a constant, so it can't be diddled with by the loop. Super-safe!","path":"Informed/Lesson One/README.md","position":105,"original_position":105,"commit_id":"48a91a5d7a5788f4174fd334b32dc6f760f25c87","original_commit_id":"48a91a5d7a5788f4174fd334b32dc6f760f25c87","user":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"body":"hah - diddled with :dancers: ","created_at":"2015-08-18T10:18:14Z","updated_at":"2015-08-18T10:18:14Z","html_url":"https://github.com/orta/Swift-at-Artsy/pull/1#discussion_r37283552","pull_request_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/comments/37283552"},"html":{"href":"https://github.com/orta/Swift-at-Artsy/pull/1#discussion_r37283552"},"pull_request":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1","id":42638575,"html_url":"https://github.com/orta/Swift-at-Artsy/pull/1","diff_url":"https://github.com/orta/Swift-at-Artsy/pull/1.diff","patch_url":"https://github.com/orta/Swift-at-Artsy/pull/1.patch","issue_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/1","number":1,"state":"open","locked":false,"title":"First draft of lesson one for informed class.","user":{"login":"ashfurrow","id":498212,"avatar_url":"https://avatars.githubusercontent.com/u/498212?v=3","gravatar_id":"","url":"https://api.github.com/users/ashfurrow","html_url":"https://github.com/ashfurrow","followers_url":"https://api.github.com/users/ashfurrow/followers","following_url":"https://api.github.com/users/ashfurrow/following{/other_user}","gists_url":"https://api.github.com/users/ashfurrow/gists{/gist_id}","starred_url":"https://api.github.com/users/ashfurrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashfurrow/subscriptions","organizations_url":"https://api.github.com/users/ashfurrow/orgs","repos_url":"https://api.github.com/users/ashfurrow/repos","events_url":"https://api.github.com/users/ashfurrow/events{/privacy}","received_events_url":"https://api.github.com/users/ashfurrow/received_events","type":"User","site_admin":false},"body":"I'm trying to make the lesson accessible in Xcode playgrounds as well as GitHub so that remote people and outsiders can use it. ","created_at":"2015-08-17T21:49:48Z","updated_at":"2015-08-18T10:18:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b533198b457a46259357f88530ec2420bee7b87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1/commits","review_comments_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1/comments","review_comment_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/1/comments","statuses_url":"https://api.github.com/repos/orta/Swift-at-Artsy/statuses/48a91a5d7a5788f4174fd334b32dc6f760f25c87","head":{"label":"orta:informed-lesson-one","ref":"informed-lesson-one","sha":"48a91a5d7a5788f4174fd334b32dc6f760f25c87","user":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"repo":{"id":40609416,"name":"Swift-at-Artsy","full_name":"orta/Swift-at-Artsy","owner":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/orta/Swift-at-Artsy","description":"Repo for the notes for Swift at Artsy","fork":false,"url":"https://api.github.com/repos/orta/Swift-at-Artsy","forks_url":"https://api.github.com/repos/orta/Swift-at-Artsy/forks","keys_url":"https://api.github.com/repos/orta/Swift-at-Artsy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orta/Swift-at-Artsy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orta/Swift-at-Artsy/teams","hooks_url":"https://api.github.com/repos/orta/Swift-at-Artsy/hooks","issue_events_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/events{/number}","events_url":"https://api.github.com/repos/orta/Swift-at-Artsy/events","assignees_url":"https://api.github.com/repos/orta/Swift-at-Artsy/assignees{/user}","branches_url":"https://api.github.com/repos/orta/Swift-at-Artsy/branches{/branch}","tags_url":"https://api.github.com/repos/orta/Swift-at-Artsy/tags","blobs_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/refs{/sha}","trees_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orta/Swift-at-Artsy/statuses/{sha}","languages_url":"https://api.github.com/repos/orta/Swift-at-Artsy/languages","stargazers_url":"https://api.github.com/repos/orta/Swift-at-Artsy/stargazers","contributors_url":"https://api.github.com/repos/orta/Swift-at-Artsy/contributors","subscribers_url":"https://api.github.com/repos/orta/Swift-at-Artsy/subscribers","subscription_url":"https://api.github.com/repos/orta/Swift-at-Artsy/subscription","commits_url":"https://api.github.com/repos/orta/Swift-at-Artsy/commits{/sha}","git_commits_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/commits{/sha}","comments_url":"https://api.github.com/repos/orta/Swift-at-Artsy/comments{/number}","issue_comment_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/comments{/number}","contents_url":"https://api.github.com/repos/orta/Swift-at-Artsy/contents/{+path}","compare_url":"https://api.github.com/repos/orta/Swift-at-Artsy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orta/Swift-at-Artsy/merges","archive_url":"https://api.github.com/repos/orta/Swift-at-Artsy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orta/Swift-at-Artsy/downloads","issues_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues{/number}","pulls_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls{/number}","milestones_url":"https://api.github.com/repos/orta/Swift-at-Artsy/milestones{/number}","notifications_url":"https://api.github.com/repos/orta/Swift-at-Artsy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orta/Swift-at-Artsy/labels{/name}","releases_url":"https://api.github.com/repos/orta/Swift-at-Artsy/releases{/id}","created_at":"2015-08-12T15:45:26Z","updated_at":"2015-08-16T08:11:48Z","pushed_at":"2015-08-17T21:49:48Z","git_url":"git://github.com/orta/Swift-at-Artsy.git","ssh_url":"git@github.com:orta/Swift-at-Artsy.git","clone_url":"https://github.com/orta/Swift-at-Artsy.git","svn_url":"https://github.com/orta/Swift-at-Artsy","homepage":null,"size":0,"stargazers_count":11,"watchers_count":11,"language":null,"has_issues":true,"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":11,"default_branch":"master"}},"base":{"label":"orta:master","ref":"master","sha":"fc0221b4a9f1f5db8bb5820fe325b771b55b25aa","user":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"repo":{"id":40609416,"name":"Swift-at-Artsy","full_name":"orta/Swift-at-Artsy","owner":{"login":"orta","id":49038,"avatar_url":"https://avatars.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/orta/Swift-at-Artsy","description":"Repo for the notes for Swift at Artsy","fork":false,"url":"https://api.github.com/repos/orta/Swift-at-Artsy","forks_url":"https://api.github.com/repos/orta/Swift-at-Artsy/forks","keys_url":"https://api.github.com/repos/orta/Swift-at-Artsy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orta/Swift-at-Artsy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orta/Swift-at-Artsy/teams","hooks_url":"https://api.github.com/repos/orta/Swift-at-Artsy/hooks","issue_events_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/events{/number}","events_url":"https://api.github.com/repos/orta/Swift-at-Artsy/events","assignees_url":"https://api.github.com/repos/orta/Swift-at-Artsy/assignees{/user}","branches_url":"https://api.github.com/repos/orta/Swift-at-Artsy/branches{/branch}","tags_url":"https://api.github.com/repos/orta/Swift-at-Artsy/tags","blobs_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/refs{/sha}","trees_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orta/Swift-at-Artsy/statuses/{sha}","languages_url":"https://api.github.com/repos/orta/Swift-at-Artsy/languages","stargazers_url":"https://api.github.com/repos/orta/Swift-at-Artsy/stargazers","contributors_url":"https://api.github.com/repos/orta/Swift-at-Artsy/contributors","subscribers_url":"https://api.github.com/repos/orta/Swift-at-Artsy/subscribers","subscription_url":"https://api.github.com/repos/orta/Swift-at-Artsy/subscription","commits_url":"https://api.github.com/repos/orta/Swift-at-Artsy/commits{/sha}","git_commits_url":"https://api.github.com/repos/orta/Swift-at-Artsy/git/commits{/sha}","comments_url":"https://api.github.com/repos/orta/Swift-at-Artsy/comments{/number}","issue_comment_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/comments{/number}","contents_url":"https://api.github.com/repos/orta/Swift-at-Artsy/contents/{+path}","compare_url":"https://api.github.com/repos/orta/Swift-at-Artsy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orta/Swift-at-Artsy/merges","archive_url":"https://api.github.com/repos/orta/Swift-at-Artsy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orta/Swift-at-Artsy/downloads","issues_url":"https://api.github.com/repos/orta/Swift-at-Artsy/issues{/number}","pulls_url":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls{/number}","milestones_url":"https://api.github.com/repos/orta/Swift-at-Artsy/milestones{/number}","notifications_url":"https://api.github.com/repos/orta/Swift-at-Artsy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orta/Swift-at-Artsy/labels{/name}","releases_url":"https://api.github.com/repos/orta/Swift-at-Artsy/releases{/id}","created_at":"2015-08-12T15:45:26Z","updated_at":"2015-08-16T08:11:48Z","pushed_at":"2015-08-17T21:49:48Z","git_url":"git://github.com/orta/Swift-at-Artsy.git","ssh_url":"git@github.com:orta/Swift-at-Artsy.git","clone_url":"https://github.com/orta/Swift-at-Artsy.git","svn_url":"https://github.com/orta/Swift-at-Artsy","homepage":null,"size":0,"stargazers_count":11,"watchers_count":11,"language":null,"has_issues":true,"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":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1"},"html":{"href":"https://github.com/orta/Swift-at-Artsy/pull/1"},"issue":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/1"},"comments":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/orta/Swift-at-Artsy/statuses/48a91a5d7a5788f4174fd334b32dc6f760f25c87"}}}}