{"action":"created","comment":{"url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/comments/63653478","id":63653478,"diff_hunk":"@@ -177,6 +182,33 @@ HashMapTest: class extends Fixture {\n \n \t\t\thashmap free()\n \t\t})\n+\t\tthis add(\"to and from file\", func {\n+\t\t\thashmap := HashMap<String, String> new()\n+\t\t\thashmap put(\"pi\", \"3.14159\")\n+\t\t\thashmap put(\"e\", \"2.71828\")\n+\t\t\thashmap put(\"sqrt(2)\", \"1.41459\")\n+\t\t\thashmap put(\"primes\", \"2,3,5,7,11,13,17\")\n+\t\t\thashmap writeToFile(\"test/system/output/mathmap.txt\")\n+\t\t\thashmap free()\n+\n+\t\t\ttolerance := 0.00001f\n+\t\t\tinput := HashMap readFromFile(t\"test/system/output/mathmap.txt\")\n+\t\t\texpect(input, is notNull)\n+\t\t\texpect(input count, is equal to(4))\n+\t\t\t(piString, eString, sqrtTwoString, primeString) := (input get(\"pi\"), input get(\"e\"), input get(\"sqrt(2)\"), input get(\"primes\"))\n+\t\t\t(pi, e, sqrtTwo) := (piString, eString, sqrtTwoString) toFloat()\n+\t\t\texpect(pi, is equal to(3.14159f) within(tolerance))\n+\t\t\texpect(e, is equal to(2.71828f) within(tolerance))\n+\t\t\texpect(sqrtTwo, is equal to(1.41459f) within(tolerance))\n+\t\t\tprimes := primeString split(',')\n+\t\t\texpect(primes count, is equal to(7))\n+\t\t\tprimes free()\n+\n+\t\t\t// Since keys/values are not string literals we need to manually free\n+\t\t\tinput each(freeFunc)","path":"test/system/HashMapTest.ooc","position":39,"original_position":39,"commit_id":"16ff22ee7891b5af842a551d62e2a82bfcb828ca","original_commit_id":"16ff22ee7891b5af842a551d62e2a82bfcb828ca","user":{"login":"marcusnaslund","id":14308896,"avatar_url":"https://avatars.githubusercontent.com/u/14308896?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusnaslund","html_url":"https://github.com/marcusnaslund","followers_url":"https://api.github.com/users/marcusnaslund/followers","following_url":"https://api.github.com/users/marcusnaslund/following{/other_user}","gists_url":"https://api.github.com/users/marcusnaslund/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusnaslund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusnaslund/subscriptions","organizations_url":"https://api.github.com/users/marcusnaslund/orgs","repos_url":"https://api.github.com/users/marcusnaslund/repos","events_url":"https://api.github.com/users/marcusnaslund/events{/privacy}","received_events_url":"https://api.github.com/users/marcusnaslund/received_events","type":"User","site_admin":false},"body":"I see your point, but...\r\n\r\n> So this will be needed everytime\r\n\r\nYes, but it's not very different from other pieces of ooc: If you throw classes in a generic something, you are also responsible for dealing with their destruction. Having a function which iterates over all entries and frees the key+value pair I thought was actually pretty neat. :)\r\n\r\n> is there some other way\r\n\r\nNo. :( I mean, we could have a method in the map like `freeAllKeyValuePairs()` which would contain a huge switch statement and try to free \"all\" types of keys and values... but that's not too practical. We *could* have a specialized one for just the <String, String> type, but that may be a bit too much specialization. What do you say?","created_at":"2016-05-18T06:51:12Z","updated_at":"2016-05-18T06:51:12Z","html_url":"https://github.com/magic-lang/ooc-kean/pull/1721#discussion_r63653478","pull_request_url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721","_links":{"self":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/comments/63653478"},"html":{"href":"https://github.com/magic-lang/ooc-kean/pull/1721#discussion_r63653478"},"pull_request":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721"}}},"pull_request":{"url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721","id":70228285,"html_url":"https://github.com/magic-lang/ooc-kean/pull/1721","diff_url":"https://github.com/magic-lang/ooc-kean/pull/1721.diff","patch_url":"https://github.com/magic-lang/ooc-kean/pull/1721.patch","issue_url":"https://api.github.com/repos/magic-lang/ooc-kean/issues/1721","number":1721,"state":"open","locked":false,"title":"Added file methods for HashMap","user":{"login":"marcusnaslund","id":14308896,"avatar_url":"https://avatars.githubusercontent.com/u/14308896?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusnaslund","html_url":"https://github.com/marcusnaslund","followers_url":"https://api.github.com/users/marcusnaslund/followers","following_url":"https://api.github.com/users/marcusnaslund/following{/other_user}","gists_url":"https://api.github.com/users/marcusnaslund/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusnaslund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusnaslund/subscriptions","organizations_url":"https://api.github.com/users/marcusnaslund/orgs","repos_url":"https://api.github.com/users/marcusnaslund/repos","events_url":"https://api.github.com/users/marcusnaslund/events{/privacy}","received_events_url":"https://api.github.com/users/marcusnaslund/received_events","type":"User","site_admin":false},"body":"Fixes #1720 \r\n\r\nIt is now possible to write the contents of a `<String, String>`-hashmap to file. They will be saved in the very simple format\r\n```\r\nkey1:value1\r\nkey2:value2\r\nkey3:value3\r\n...\r\n```\r\nThese files can also be read in to create a new `HashMap<String, String>`. Lines with zero (or more than one) colon will be ignored.\r\n\r\n---\r\n\r\nThis is pretty neat:\r\n```ooc\r\nnumbers := HashMap readFromFile(\"mynumbers.txt\")\r\nevenNumberString := numbers get(\"even\") split(',')\r\nevenNumbers := IntVectorList new()\r\nfor (i in 0 .. evenNumberString count)\r\n    evenNumbers add(evenNumbers[i] toInt())\r\n```\r\n\r\n---\r\n\r\nYes, `readFromFile` takes a `Text` argument and `writeToFile` takes a `String` argument... since this is what's expected from `FileReader` and `FileWriter`, respectively. This is a mess we need to figure out.\r\n","created_at":"2016-05-16T17:12:18Z","updated_at":"2016-05-18T06:51:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe121782eb2f0ca911b290a51998649f2e309ec7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721/commits","review_comments_url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721/comments","review_comment_url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/comments{/number}","comments_url":"https://api.github.com/repos/magic-lang/ooc-kean/issues/1721/comments","statuses_url":"https://api.github.com/repos/magic-lang/ooc-kean/statuses/16ff22ee7891b5af842a551d62e2a82bfcb828ca","head":{"label":"marcusnaslund:hashfile","ref":"hashfile","sha":"16ff22ee7891b5af842a551d62e2a82bfcb828ca","user":{"login":"marcusnaslund","id":14308896,"avatar_url":"https://avatars.githubusercontent.com/u/14308896?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusnaslund","html_url":"https://github.com/marcusnaslund","followers_url":"https://api.github.com/users/marcusnaslund/followers","following_url":"https://api.github.com/users/marcusnaslund/following{/other_user}","gists_url":"https://api.github.com/users/marcusnaslund/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusnaslund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusnaslund/subscriptions","organizations_url":"https://api.github.com/users/marcusnaslund/orgs","repos_url":"https://api.github.com/users/marcusnaslund/repos","events_url":"https://api.github.com/users/marcusnaslund/events{/privacy}","received_events_url":"https://api.github.com/users/marcusnaslund/received_events","type":"User","site_admin":false},"repo":{"id":42990201,"name":"ooc-kean","full_name":"marcusnaslund/ooc-kean","owner":{"login":"marcusnaslund","id":14308896,"avatar_url":"https://avatars.githubusercontent.com/u/14308896?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusnaslund","html_url":"https://github.com/marcusnaslund","followers_url":"https://api.github.com/users/marcusnaslund/followers","following_url":"https://api.github.com/users/marcusnaslund/following{/other_user}","gists_url":"https://api.github.com/users/marcusnaslund/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusnaslund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusnaslund/subscriptions","organizations_url":"https://api.github.com/users/marcusnaslund/orgs","repos_url":"https://api.github.com/users/marcusnaslund/repos","events_url":"https://api.github.com/users/marcusnaslund/events{/privacy}","received_events_url":"https://api.github.com/users/marcusnaslund/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marcusnaslund/ooc-kean","description":"ooc port of parts of Kean.","fork":true,"url":"https://api.github.com/repos/marcusnaslund/ooc-kean","forks_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/forks","keys_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/teams","hooks_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/hooks","issue_events_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/issues/events{/number}","events_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/events","assignees_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/assignees{/user}","branches_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/branches{/branch}","tags_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/tags","blobs_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/git/refs{/sha}","trees_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/statuses/{sha}","languages_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/languages","stargazers_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/stargazers","contributors_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/contributors","subscribers_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/subscribers","subscription_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/subscription","commits_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/commits{/sha}","git_commits_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/git/commits{/sha}","comments_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/comments{/number}","issue_comment_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/issues/comments{/number}","contents_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/contents/{+path}","compare_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/merges","archive_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/downloads","issues_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/issues{/number}","pulls_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/pulls{/number}","milestones_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/milestones{/number}","notifications_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/labels{/name}","releases_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/releases{/id}","deployments_url":"https://api.github.com/repos/marcusnaslund/ooc-kean/deployments","created_at":"2015-09-23T09:03:37Z","updated_at":"2016-01-11T09:02:09Z","pushed_at":"2016-05-17T08:45:02Z","git_url":"git://github.com/marcusnaslund/ooc-kean.git","ssh_url":"git@github.com:marcusnaslund/ooc-kean.git","clone_url":"https://github.com/marcusnaslund/ooc-kean.git","svn_url":"https://github.com/marcusnaslund/ooc-kean","homepage":"","size":31803,"stargazers_count":0,"watchers_count":0,"language":"ooc","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"magic-lang:develop","ref":"develop","sha":"176cc45bb57b7d8e46181273b7eba39d85eec97a","user":{"login":"magic-lang","id":16756691,"avatar_url":"https://avatars.githubusercontent.com/u/16756691?v=3","gravatar_id":"","url":"https://api.github.com/users/magic-lang","html_url":"https://github.com/magic-lang","followers_url":"https://api.github.com/users/magic-lang/followers","following_url":"https://api.github.com/users/magic-lang/following{/other_user}","gists_url":"https://api.github.com/users/magic-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/magic-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magic-lang/subscriptions","organizations_url":"https://api.github.com/users/magic-lang/orgs","repos_url":"https://api.github.com/users/magic-lang/repos","events_url":"https://api.github.com/users/magic-lang/events{/privacy}","received_events_url":"https://api.github.com/users/magic-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":25256330,"name":"ooc-kean","full_name":"magic-lang/ooc-kean","owner":{"login":"magic-lang","id":16756691,"avatar_url":"https://avatars.githubusercontent.com/u/16756691?v=3","gravatar_id":"","url":"https://api.github.com/users/magic-lang","html_url":"https://github.com/magic-lang","followers_url":"https://api.github.com/users/magic-lang/followers","following_url":"https://api.github.com/users/magic-lang/following{/other_user}","gists_url":"https://api.github.com/users/magic-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/magic-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magic-lang/subscriptions","organizations_url":"https://api.github.com/users/magic-lang/orgs","repos_url":"https://api.github.com/users/magic-lang/repos","events_url":"https://api.github.com/users/magic-lang/events{/privacy}","received_events_url":"https://api.github.com/users/magic-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/magic-lang/ooc-kean","description":"ooc port of parts of Kean.","fork":false,"url":"https://api.github.com/repos/magic-lang/ooc-kean","forks_url":"https://api.github.com/repos/magic-lang/ooc-kean/forks","keys_url":"https://api.github.com/repos/magic-lang/ooc-kean/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magic-lang/ooc-kean/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magic-lang/ooc-kean/teams","hooks_url":"https://api.github.com/repos/magic-lang/ooc-kean/hooks","issue_events_url":"https://api.github.com/repos/magic-lang/ooc-kean/issues/events{/number}","events_url":"https://api.github.com/repos/magic-lang/ooc-kean/events","assignees_url":"https://api.github.com/repos/magic-lang/ooc-kean/assignees{/user}","branches_url":"https://api.github.com/repos/magic-lang/ooc-kean/branches{/branch}","tags_url":"https://api.github.com/repos/magic-lang/ooc-kean/tags","blobs_url":"https://api.github.com/repos/magic-lang/ooc-kean/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magic-lang/ooc-kean/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magic-lang/ooc-kean/git/refs{/sha}","trees_url":"https://api.github.com/repos/magic-lang/ooc-kean/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magic-lang/ooc-kean/statuses/{sha}","languages_url":"https://api.github.com/repos/magic-lang/ooc-kean/languages","stargazers_url":"https://api.github.com/repos/magic-lang/ooc-kean/stargazers","contributors_url":"https://api.github.com/repos/magic-lang/ooc-kean/contributors","subscribers_url":"https://api.github.com/repos/magic-lang/ooc-kean/subscribers","subscription_url":"https://api.github.com/repos/magic-lang/ooc-kean/subscription","commits_url":"https://api.github.com/repos/magic-lang/ooc-kean/commits{/sha}","git_commits_url":"https://api.github.com/repos/magic-lang/ooc-kean/git/commits{/sha}","comments_url":"https://api.github.com/repos/magic-lang/ooc-kean/comments{/number}","issue_comment_url":"https://api.github.com/repos/magic-lang/ooc-kean/issues/comments{/number}","contents_url":"https://api.github.com/repos/magic-lang/ooc-kean/contents/{+path}","compare_url":"https://api.github.com/repos/magic-lang/ooc-kean/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magic-lang/ooc-kean/merges","archive_url":"https://api.github.com/repos/magic-lang/ooc-kean/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magic-lang/ooc-kean/downloads","issues_url":"https://api.github.com/repos/magic-lang/ooc-kean/issues{/number}","pulls_url":"https://api.github.com/repos/magic-lang/ooc-kean/pulls{/number}","milestones_url":"https://api.github.com/repos/magic-lang/ooc-kean/milestones{/number}","notifications_url":"https://api.github.com/repos/magic-lang/ooc-kean/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magic-lang/ooc-kean/labels{/name}","releases_url":"https://api.github.com/repos/magic-lang/ooc-kean/releases{/id}","deployments_url":"https://api.github.com/repos/magic-lang/ooc-kean/deployments","created_at":"2014-10-15T13:42:17Z","updated_at":"2016-03-02T07:55:35Z","pushed_at":"2016-05-18T06:41:27Z","git_url":"git://github.com/magic-lang/ooc-kean.git","ssh_url":"git@github.com:magic-lang/ooc-kean.git","clone_url":"https://github.com/magic-lang/ooc-kean.git","svn_url":"https://github.com/magic-lang/ooc-kean","homepage":"","size":35250,"stargazers_count":4,"watchers_count":4,"language":"ooc","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":22,"forks":23,"open_issues":22,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721"},"html":{"href":"https://github.com/magic-lang/ooc-kean/pull/1721"},"issue":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/issues/1721"},"comments":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/issues/1721/comments"},"review_comments":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721/comments"},"review_comment":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/pulls/1721/commits"},"statuses":{"href":"https://api.github.com/repos/magic-lang/ooc-kean/statuses/16ff22ee7891b5af842a551d62e2a82bfcb828ca"}}}}