{"action":"created","issue":{"url":"https://api.github.com/repos/Kotlin/KEEP/issues/112","repository_url":"https://api.github.com/repos/Kotlin/KEEP","labels_url":"https://api.github.com/repos/Kotlin/KEEP/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/Kotlin/KEEP/issues/112/comments","events_url":"https://api.github.com/repos/Kotlin/KEEP/issues/112/events","html_url":"https://github.com/Kotlin/KEEP/pull/112","id":322619679,"number":112,"title":"Collection literals","user":{"login":"BenLeggiero","id":10189808,"avatar_url":"https://avatars0.githubusercontent.com/u/10189808?v=4","gravatar_id":"","url":"https://api.github.com/users/BenLeggiero","html_url":"https://github.com/BenLeggiero","followers_url":"https://api.github.com/users/BenLeggiero/followers","following_url":"https://api.github.com/users/BenLeggiero/following{/other_user}","gists_url":"https://api.github.com/users/BenLeggiero/gists{/gist_id}","starred_url":"https://api.github.com/users/BenLeggiero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenLeggiero/subscriptions","organizations_url":"https://api.github.com/users/BenLeggiero/orgs","repos_url":"https://api.github.com/users/BenLeggiero/repos","events_url":"https://api.github.com/users/BenLeggiero/events{/privacy}","received_events_url":"https://api.github.com/users/BenLeggiero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-05-13T19:17:17Z","updated_at":"2018-05-23T06:42:42Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Kotlin/KEEP/pulls/112","html_url":"https://github.com/Kotlin/KEEP/pull/112","diff_url":"https://github.com/Kotlin/KEEP/pull/112.diff","patch_url":"https://github.com/Kotlin/KEEP/pull/112.patch"},"body":"Discussion of this proposal:\r\nhttps://github.com/BenLeggiero/KEEP/blob/collection-literals/proposals/collection-literals.md\r\n\r\nRelated issue is #113 "},"comment":{"url":"https://api.github.com/repos/Kotlin/KEEP/issues/comments/391237807","html_url":"https://github.com/Kotlin/KEEP/pull/112#issuecomment-391237807","issue_url":"https://api.github.com/repos/Kotlin/KEEP/issues/112","id":391237807,"user":{"login":"helmbold","id":5079980,"avatar_url":"https://avatars1.githubusercontent.com/u/5079980?v=4","gravatar_id":"","url":"https://api.github.com/users/helmbold","html_url":"https://github.com/helmbold","followers_url":"https://api.github.com/users/helmbold/followers","following_url":"https://api.github.com/users/helmbold/following{/other_user}","gists_url":"https://api.github.com/users/helmbold/gists{/gist_id}","starred_url":"https://api.github.com/users/helmbold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helmbold/subscriptions","organizations_url":"https://api.github.com/users/helmbold/orgs","repos_url":"https://api.github.com/users/helmbold/repos","events_url":"https://api.github.com/users/helmbold/events{/privacy}","received_events_url":"https://api.github.com/users/helmbold/received_events","type":"User","site_admin":false},"created_at":"2018-05-23T06:42:42Z","updated_at":"2018-05-23T06:42:42Z","author_association":"NONE","body":"@accursoft If collections literals are used for passing them as parameters, one could pass the collection elements as `vararg`, at least if there is only one such parameter in a method call. Otherwise it would possible to use a builder.\r\n\r\nTo translate your example in this style:\r\n\r\n```kotlin\r\nfun foo(vararg list: Int) = ...\r\nfoo(1, 2, 3)\r\n```\r\n\r\nThe builder style would look like this:\r\n\r\n```kotlin\r\nSomethingComplex.a(1, 2, 3).b(2, 4, 6, 8).c(\"one\" to 1, \"two\" to 2).build()\r\n```\r\n\r\nWhere \r\n\r\n* `a` is a `List`\r\n* `b` is a `Set`\r\n* `c` is a `Map`\r\n\r\nThe builder in this example would look like this:\r\n\r\n```kotlin\r\nclass SomethingComplex(a: List<Int>, b: Set<Int>, c: Map<String, Int>) {\r\n  \r\n    // do something useful with a, b, and c\r\n    \r\n    class Builder(private val a: List<Int>) {\r\n        private var b = setOf<Int>()\r\n        private var c = mapOf<String, Int>()\r\n        \r\n        fun b(vararg b: Int) : Builder {\r\n            this.b = b.toSet()\r\n            return this\r\n        }\r\n        \r\n        fun c(vararg items: Pair<String, Int>) {\r\n            this.c = items.toMap()\r\n        }\r\n        \r\n        fun build() = SomethingComplex(a, b, c)\r\n    }\r\n    \r\n    companion object {\r\n        fun a(vararg a: Int) = Builder(a.toList())\r\n    }\r\n}\r\n```\r\nSo it is relatively easy to make nice APIs without collection literals."}}
{"actor":{"display_login":"helmbold"}}