{"action":"created","comment":{"url":"https://api.github.com/repos/inancgumus/learngo/pulls/comments/328890119","pull_request_review_id":294084528,"id":328890119,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMyODg5MDExOQ==","diff_hunk":"@@ -1,84 +1,83 @@\n-## How to fix this program?\n+# Questions: Short If #\n+\n+## 1. Which of the choices below would fix the following program? ##\n ```go\n package main\n \n import (\n-\t\"fmt\"\n-\t\"time\"\n+    \"fmt\"\n+    \"time\"\n )\n \n func main() {\n-\tif err != nil; d, err := time.ParseDuration(\"1h10s\") {\n-\t\tfmt.Println(d)\n-\t}\n+    if err != nil; d, err != time.ParseDuration(\"1h10s\") {\n+        fmt.Println(d)\n+    }\n }\n-``` -\n-1. Swap the simple statement with the `err != nil` check. *CORRECT*\n-2. Remove the error handling.\n-3. Remove the semicolon.\n-4. Change the short declaration to an assignment.\n+```\n+(A) Swapping the simple statement with `err != check`. <br>\n+(B) Removing the error handling. <br>\n+(C) Removing the remove the semicolon. <br>\n+(D) Changing the short declaration to an assignment. <br>\n+\n+---\n \n-> **1:** Yes. In a short if statement, the simple statement (the short declaration there) should be the first part of it. Then, after the semicolon separator, there should be a condition expression.\n-> \n-> **2:** You don't want that. That's not the issue here.\n+**Solution**: (A) <br>\n+When initalizing the short if-statement, the simple statement (the short declaration short come first. Only after the semicolon should the separator should there be a conditional expression.\n \n+Removing the error handler is not the is not the issues and the semicolons are valid end of statement separator. Changing the short declaration to an assignment would not work because it would no longer be a conditional.\n \n-## What does this program print?\n+## 2. What does the following program print to the console? ##\n ```go\n-package main\n+package main \n import \"fmt\"\n \n func main() {\n-\tdone := false\n-\tif done := true; done {\n-\t\tfmt.Println(done)\n-\t}\n-\tfmt.Println(done)\n+    done := false\n+    if done != true; done {\n+        fmt.Println(done)\n+    }\n+    fmt.Println(done)\n }\n ```\n-1. true and true\n-2. false and false\n-3. true and false *CORRECT*\n-4. false and true\n-\n-> **3:** Yes. It shadows the main()'s done variable, and inside the if statement, it prints \"true\". Then, after the if statement ends, it prints the main()'s done variable which is \"false\".\n+(A) true and false <br>\n+(B) false and false <br>\n+(C) true and false <br>\n+(D) false and true <br>\n \n+---\n \n-## There's a shadowing issue in this program. The program should print: 10, now it prints: 0.\n-\n-**How can you fix this it?**\n+**Solution**: (C)\n+The program shadows the variable `done` in the `main()` function. Inside the if-statement, it prints `true`. The program prints false at the end because the values inside the if-statement don't affect the values of variables outside of it.\n \n+## 3. There's a shadowing issue in the following program. The program should print `10` but instead prints `0`. Which of the following choices would fix the program? ##\n ```go\n package main\n \n import (\n-  \"fmt\"\n-  \"strconv\"\n+    \"fmt\"\n+    \"strconv\"\n )\n \n func main() {\n-  var n int\n-\n-  if n, err := strconv.Atoi(\"10\"); err != nil {\n-    fmt.Printf(\"error: %s (n: %d)\", err, n)\n-    return\n-  }\n-\n-  fmt.Println(n)\n+    var n int\n+    \n+    if n, err := strconv.Atoi(\"10\"); err != nil {\n+        fmt.Printf(\"error: %s (n: %d}\", err, n)\n+        return\n+    } \n+    \n+    fmt.Pritnln(n)\n }\n ```\n+_You can also see the code using Go Plaground [here](https://play.golang.org/p/fDrmcXWGnQB)","path":"11-if/questions/5-short-if-edit.md","position":73,"original_position":113,"commit_id":"a6be8fa861917cc953426002cd9ff4d964067c0d","original_commit_id":"a6be8fa861917cc953426002cd9ff4d964067c0d","user":{"login":"jarrodchung-dev","id":53537663,"node_id":"MDQ6VXNlcjUzNTM3NjYz","avatar_url":"https://avatars2.githubusercontent.com/u/53537663?v=4","gravatar_id":"","url":"https://api.github.com/users/jarrodchung-dev","html_url":"https://github.com/jarrodchung-dev","followers_url":"https://api.github.com/users/jarrodchung-dev/followers","following_url":"https://api.github.com/users/jarrodchung-dev/following{/other_user}","gists_url":"https://api.github.com/users/jarrodchung-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrodchung-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrodchung-dev/subscriptions","organizations_url":"https://api.github.com/users/jarrodchung-dev/orgs","repos_url":"https://api.github.com/users/jarrodchung-dev/repos","events_url":"https://api.github.com/users/jarrodchung-dev/events{/privacy}","received_events_url":"https://api.github.com/users/jarrodchung-dev/received_events","type":"User","site_admin":false},"body":"**Fixed**:\r\n---\r\nClick [here](https://play.golang.org/p/6jc-nZJNHYb) to see the solution on Go Playground.","created_at":"2019-09-27T02:08:44Z","updated_at":"2019-09-27T02:08:45Z","html_url":"https://github.com/inancgumus/learngo/pull/22#discussion_r328890119","pull_request_url":"https://api.github.com/repos/inancgumus/learngo/pulls/22","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/comments/328890119"},"html":{"href":"https://github.com/inancgumus/learngo/pull/22#discussion_r328890119"},"pull_request":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/22"}},"in_reply_to_id":328484063},"pull_request":{"url":"https://api.github.com/repos/inancgumus/learngo/pulls/22","id":321320954,"node_id":"MDExOlB1bGxSZXF1ZXN0MzIxMzIwOTU0","html_url":"https://github.com/inancgumus/learngo/pull/22","diff_url":"https://github.com/inancgumus/learngo/pull/22.diff","patch_url":"https://github.com/inancgumus/learngo/pull/22.patch","issue_url":"https://api.github.com/repos/inancgumus/learngo/issues/22","number":22,"state":"open","locked":false,"title":"Submitting sections 02 & 03 for review","user":{"login":"jarrodchung-dev","id":53537663,"node_id":"MDQ6VXNlcjUzNTM3NjYz","avatar_url":"https://avatars2.githubusercontent.com/u/53537663?v=4","gravatar_id":"","url":"https://api.github.com/users/jarrodchung-dev","html_url":"https://github.com/jarrodchung-dev","followers_url":"https://api.github.com/users/jarrodchung-dev/followers","following_url":"https://api.github.com/users/jarrodchung-dev/following{/other_user}","gists_url":"https://api.github.com/users/jarrodchung-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrodchung-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrodchung-dev/subscriptions","organizations_url":"https://api.github.com/users/jarrodchung-dev/orgs","repos_url":"https://api.github.com/users/jarrodchung-dev/repos","events_url":"https://api.github.com/users/jarrodchung-dev/events{/privacy}","received_events_url":"https://api.github.com/users/jarrodchung-dev/received_events","type":"User","site_admin":false},"body":"","created_at":"2019-09-25T15:54:56Z","updated_at":"2019-09-27T02:08:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39c7281af3636e20908252ce85998f1d2d1e5019","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/inancgumus/learngo/pulls/22/commits","review_comments_url":"https://api.github.com/repos/inancgumus/learngo/pulls/22/comments","review_comment_url":"https://api.github.com/repos/inancgumus/learngo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inancgumus/learngo/issues/22/comments","statuses_url":"https://api.github.com/repos/inancgumus/learngo/statuses/a6be8fa861917cc953426002cd9ff4d964067c0d","head":{"label":"jarrodchung-dev:master","ref":"master","sha":"a6be8fa861917cc953426002cd9ff4d964067c0d","user":{"login":"jarrodchung-dev","id":53537663,"node_id":"MDQ6VXNlcjUzNTM3NjYz","avatar_url":"https://avatars2.githubusercontent.com/u/53537663?v=4","gravatar_id":"","url":"https://api.github.com/users/jarrodchung-dev","html_url":"https://github.com/jarrodchung-dev","followers_url":"https://api.github.com/users/jarrodchung-dev/followers","following_url":"https://api.github.com/users/jarrodchung-dev/following{/other_user}","gists_url":"https://api.github.com/users/jarrodchung-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrodchung-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrodchung-dev/subscriptions","organizations_url":"https://api.github.com/users/jarrodchung-dev/orgs","repos_url":"https://api.github.com/users/jarrodchung-dev/repos","events_url":"https://api.github.com/users/jarrodchung-dev/events{/privacy}","received_events_url":"https://api.github.com/users/jarrodchung-dev/received_events","type":"User","site_admin":false},"repo":{"id":210750973,"node_id":"MDEwOlJlcG9zaXRvcnkyMTA3NTA5NzM=","name":"learngo","full_name":"jarrodchung-dev/learngo","private":false,"owner":{"login":"jarrodchung-dev","id":53537663,"node_id":"MDQ6VXNlcjUzNTM3NjYz","avatar_url":"https://avatars2.githubusercontent.com/u/53537663?v=4","gravatar_id":"","url":"https://api.github.com/users/jarrodchung-dev","html_url":"https://github.com/jarrodchung-dev","followers_url":"https://api.github.com/users/jarrodchung-dev/followers","following_url":"https://api.github.com/users/jarrodchung-dev/following{/other_user}","gists_url":"https://api.github.com/users/jarrodchung-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrodchung-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrodchung-dev/subscriptions","organizations_url":"https://api.github.com/users/jarrodchung-dev/orgs","repos_url":"https://api.github.com/users/jarrodchung-dev/repos","events_url":"https://api.github.com/users/jarrodchung-dev/events{/privacy}","received_events_url":"https://api.github.com/users/jarrodchung-dev/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jarrodchung-dev/learngo","description":"1000+ Hand-Crafted Go Examples, Exercises, and Quizzes","fork":true,"url":"https://api.github.com/repos/jarrodchung-dev/learngo","forks_url":"https://api.github.com/repos/jarrodchung-dev/learngo/forks","keys_url":"https://api.github.com/repos/jarrodchung-dev/learngo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jarrodchung-dev/learngo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jarrodchung-dev/learngo/teams","hooks_url":"https://api.github.com/repos/jarrodchung-dev/learngo/hooks","issue_events_url":"https://api.github.com/repos/jarrodchung-dev/learngo/issues/events{/number}","events_url":"https://api.github.com/repos/jarrodchung-dev/learngo/events","assignees_url":"https://api.github.com/repos/jarrodchung-dev/learngo/assignees{/user}","branches_url":"https://api.github.com/repos/jarrodchung-dev/learngo/branches{/branch}","tags_url":"https://api.github.com/repos/jarrodchung-dev/learngo/tags","blobs_url":"https://api.github.com/repos/jarrodchung-dev/learngo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jarrodchung-dev/learngo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jarrodchung-dev/learngo/git/refs{/sha}","trees_url":"https://api.github.com/repos/jarrodchung-dev/learngo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jarrodchung-dev/learngo/statuses/{sha}","languages_url":"https://api.github.com/repos/jarrodchung-dev/learngo/languages","stargazers_url":"https://api.github.com/repos/jarrodchung-dev/learngo/stargazers","contributors_url":"https://api.github.com/repos/jarrodchung-dev/learngo/contributors","subscribers_url":"https://api.github.com/repos/jarrodchung-dev/learngo/subscribers","subscription_url":"https://api.github.com/repos/jarrodchung-dev/learngo/subscription","commits_url":"https://api.github.com/repos/jarrodchung-dev/learngo/commits{/sha}","git_commits_url":"https://api.github.com/repos/jarrodchung-dev/learngo/git/commits{/sha}","comments_url":"https://api.github.com/repos/jarrodchung-dev/learngo/comments{/number}","issue_comment_url":"https://api.github.com/repos/jarrodchung-dev/learngo/issues/comments{/number}","contents_url":"https://api.github.com/repos/jarrodchung-dev/learngo/contents/{+path}","compare_url":"https://api.github.com/repos/jarrodchung-dev/learngo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jarrodchung-dev/learngo/merges","archive_url":"https://api.github.com/repos/jarrodchung-dev/learngo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jarrodchung-dev/learngo/downloads","issues_url":"https://api.github.com/repos/jarrodchung-dev/learngo/issues{/number}","pulls_url":"https://api.github.com/repos/jarrodchung-dev/learngo/pulls{/number}","milestones_url":"https://api.github.com/repos/jarrodchung-dev/learngo/milestones{/number}","notifications_url":"https://api.github.com/repos/jarrodchung-dev/learngo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jarrodchung-dev/learngo/labels{/name}","releases_url":"https://api.github.com/repos/jarrodchung-dev/learngo/releases{/id}","deployments_url":"https://api.github.com/repos/jarrodchung-dev/learngo/deployments","created_at":"2019-09-25T03:52:20Z","updated_at":"2019-09-26T05:52:41Z","pushed_at":"2019-09-26T05:52:39Z","git_url":"git://github.com/jarrodchung-dev/learngo.git","ssh_url":"git@github.com:jarrodchung-dev/learngo.git","clone_url":"https://github.com/jarrodchung-dev/learngo.git","svn_url":"https://github.com/jarrodchung-dev/learngo","homepage":"https://blog.learngoprogramming.com","size":2160,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inancgumus:master","ref":"master","sha":"c4fec660fac4cd291f8063bdaae99dcd9a8772df","user":{"login":"inancgumus","id":621232,"node_id":"MDQ6VXNlcjYyMTIzMg==","avatar_url":"https://avatars3.githubusercontent.com/u/621232?v=4","gravatar_id":"","url":"https://api.github.com/users/inancgumus","html_url":"https://github.com/inancgumus","followers_url":"https://api.github.com/users/inancgumus/followers","following_url":"https://api.github.com/users/inancgumus/following{/other_user}","gists_url":"https://api.github.com/users/inancgumus/gists{/gist_id}","starred_url":"https://api.github.com/users/inancgumus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inancgumus/subscriptions","organizations_url":"https://api.github.com/users/inancgumus/orgs","repos_url":"https://api.github.com/users/inancgumus/repos","events_url":"https://api.github.com/users/inancgumus/events{/privacy}","received_events_url":"https://api.github.com/users/inancgumus/received_events","type":"User","site_admin":false},"repo":{"id":153099672,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMwOTk2NzI=","name":"learngo","full_name":"inancgumus/learngo","private":false,"owner":{"login":"inancgumus","id":621232,"node_id":"MDQ6VXNlcjYyMTIzMg==","avatar_url":"https://avatars3.githubusercontent.com/u/621232?v=4","gravatar_id":"","url":"https://api.github.com/users/inancgumus","html_url":"https://github.com/inancgumus","followers_url":"https://api.github.com/users/inancgumus/followers","following_url":"https://api.github.com/users/inancgumus/following{/other_user}","gists_url":"https://api.github.com/users/inancgumus/gists{/gist_id}","starred_url":"https://api.github.com/users/inancgumus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inancgumus/subscriptions","organizations_url":"https://api.github.com/users/inancgumus/orgs","repos_url":"https://api.github.com/users/inancgumus/repos","events_url":"https://api.github.com/users/inancgumus/events{/privacy}","received_events_url":"https://api.github.com/users/inancgumus/received_events","type":"User","site_admin":false},"html_url":"https://github.com/inancgumus/learngo","description":"1000+ Hand-Crafted Go Examples, Exercises, and Quizzes","fork":false,"url":"https://api.github.com/repos/inancgumus/learngo","forks_url":"https://api.github.com/repos/inancgumus/learngo/forks","keys_url":"https://api.github.com/repos/inancgumus/learngo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inancgumus/learngo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inancgumus/learngo/teams","hooks_url":"https://api.github.com/repos/inancgumus/learngo/hooks","issue_events_url":"https://api.github.com/repos/inancgumus/learngo/issues/events{/number}","events_url":"https://api.github.com/repos/inancgumus/learngo/events","assignees_url":"https://api.github.com/repos/inancgumus/learngo/assignees{/user}","branches_url":"https://api.github.com/repos/inancgumus/learngo/branches{/branch}","tags_url":"https://api.github.com/repos/inancgumus/learngo/tags","blobs_url":"https://api.github.com/repos/inancgumus/learngo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inancgumus/learngo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inancgumus/learngo/git/refs{/sha}","trees_url":"https://api.github.com/repos/inancgumus/learngo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inancgumus/learngo/statuses/{sha}","languages_url":"https://api.github.com/repos/inancgumus/learngo/languages","stargazers_url":"https://api.github.com/repos/inancgumus/learngo/stargazers","contributors_url":"https://api.github.com/repos/inancgumus/learngo/contributors","subscribers_url":"https://api.github.com/repos/inancgumus/learngo/subscribers","subscription_url":"https://api.github.com/repos/inancgumus/learngo/subscription","commits_url":"https://api.github.com/repos/inancgumus/learngo/commits{/sha}","git_commits_url":"https://api.github.com/repos/inancgumus/learngo/git/commits{/sha}","comments_url":"https://api.github.com/repos/inancgumus/learngo/comments{/number}","issue_comment_url":"https://api.github.com/repos/inancgumus/learngo/issues/comments{/number}","contents_url":"https://api.github.com/repos/inancgumus/learngo/contents/{+path}","compare_url":"https://api.github.com/repos/inancgumus/learngo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inancgumus/learngo/merges","archive_url":"https://api.github.com/repos/inancgumus/learngo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inancgumus/learngo/downloads","issues_url":"https://api.github.com/repos/inancgumus/learngo/issues{/number}","pulls_url":"https://api.github.com/repos/inancgumus/learngo/pulls{/number}","milestones_url":"https://api.github.com/repos/inancgumus/learngo/milestones{/number}","notifications_url":"https://api.github.com/repos/inancgumus/learngo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inancgumus/learngo/labels{/name}","releases_url":"https://api.github.com/repos/inancgumus/learngo/releases{/id}","deployments_url":"https://api.github.com/repos/inancgumus/learngo/deployments","created_at":"2018-10-15T11:12:00Z","updated_at":"2019-09-25T18:50:56Z","pushed_at":"2019-09-26T05:52:40Z","git_url":"git://github.com/inancgumus/learngo.git","ssh_url":"git@github.com:inancgumus/learngo.git","clone_url":"https://github.com/inancgumus/learngo.git","svn_url":"https://github.com/inancgumus/learngo","homepage":"https://blog.learngoprogramming.com","size":2139,"stargazers_count":426,"watchers_count":426,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":130,"open_issues":1,"watchers":426,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/22"},"html":{"href":"https://github.com/inancgumus/learngo/pull/22"},"issue":{"href":"https://api.github.com/repos/inancgumus/learngo/issues/22"},"comments":{"href":"https://api.github.com/repos/inancgumus/learngo/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inancgumus/learngo/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/inancgumus/learngo/statuses/a6be8fa861917cc953426002cd9ff4d964067c0d"}},"author_association":"NONE"}}
{"actor":{"display_login":"jarrodchung-dev"}}