{"action":"created","comment":{"url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/comments/43055357","id":43055357,"diff_hunk":"@@ -77,7 +77,30 @@ extension ObservableType {\n         }\n     }\n }\n+\n+// MARK: takeLast\n+\n+extension ObservableType {\n     \n+    /**\n+    Returns a specified number of the last elements before the observable sequence completed.\n+     \n+     - parameter count: The number of elements to return.\n+     - returns: An observable sequence that contains the specified number of elements from the end of the input sequence.\n+     */\n+    @warn_unused_result(message=\"http://git.io/rxs.uo\")\n+    public func takeLast(count: Int)\n+        -> Observable<E> {\n+        if count == 0 {\n+            return empty()\n+        }\n+        else {\n+            return TakeLast(source: self.asObservable(), count: count)\n+        }","path":"RxSwift/Observables/Observable+StandardSequenceOperators.swift","position":23,"original_position":23,"commit_id":"cc8e57a8964d89807e7ee8cd1a39ec47d1b69026","original_commit_id":"cc8e57a8964d89807e7ee8cd1a39ec47d1b69026","user":{"login":"kzaher","id":1641148,"avatar_url":"https://avatars.githubusercontent.com/u/1641148?v=3","gravatar_id":"","url":"https://api.github.com/users/kzaher","html_url":"https://github.com/kzaher","followers_url":"https://api.github.com/users/kzaher/followers","following_url":"https://api.github.com/users/kzaher/following{/other_user}","gists_url":"https://api.github.com/users/kzaher/gists{/gist_id}","starred_url":"https://api.github.com/users/kzaher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzaher/subscriptions","organizations_url":"https://api.github.com/users/kzaher/orgs","repos_url":"https://api.github.com/users/kzaher/repos","events_url":"https://api.github.com/users/kzaher/events{/privacy}","received_events_url":"https://api.github.com/users/kzaher/received_events","type":"User","site_admin":false},"body":"I think that optimization makes sense in the case of taking first elements, but when taking 0 elements from end, that's not equivalent to `empty` because sequence can error out before it completes, and that would diverge in this case.\r\n\r\nTLDR, just remove\r\n```\r\nif count == 0 {\r\n+            return empty()\r\n+        }\r\n+        else {\r\n```\r\n\r\n:)","created_at":"2015-10-26T21:24:44Z","updated_at":"2015-10-26T21:24:44Z","html_url":"https://github.com/ReactiveX/RxSwift/pull/214#discussion_r43055357","pull_request_url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214","_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/comments/43055357"},"html":{"href":"https://github.com/ReactiveX/RxSwift/pull/214#discussion_r43055357"},"pull_request":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214"}}},"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214","id":48786065,"html_url":"https://github.com/ReactiveX/RxSwift/pull/214","diff_url":"https://github.com/ReactiveX/RxSwift/pull/214.diff","patch_url":"https://github.com/ReactiveX/RxSwift/pull/214.patch","issue_url":"https://api.github.com/repos/ReactiveX/RxSwift/issues/214","number":214,"state":"open","locked":false,"title":"TakeLast operator","user":{"login":"tottakai","id":848916,"avatar_url":"https://avatars.githubusercontent.com/u/848916?v=3","gravatar_id":"","url":"https://api.github.com/users/tottakai","html_url":"https://github.com/tottakai","followers_url":"https://api.github.com/users/tottakai/followers","following_url":"https://api.github.com/users/tottakai/following{/other_user}","gists_url":"https://api.github.com/users/tottakai/gists{/gist_id}","starred_url":"https://api.github.com/users/tottakai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tottakai/subscriptions","organizations_url":"https://api.github.com/users/tottakai/orgs","repos_url":"https://api.github.com/users/tottakai/repos","events_url":"https://api.github.com/users/tottakai/events{/privacy}","received_events_url":"https://api.github.com/users/tottakai/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-26T19:31:52Z","updated_at":"2015-10-26T21:24:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d38618bb1802629b99be5fd1a311e82124ac8845","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214/commits","review_comments_url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214/comments","review_comment_url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ReactiveX/RxSwift/issues/214/comments","statuses_url":"https://api.github.com/repos/ReactiveX/RxSwift/statuses/cc8e57a8964d89807e7ee8cd1a39ec47d1b69026","head":{"label":"tottakai:feature-takelast-operator","ref":"feature-takelast-operator","sha":"cc8e57a8964d89807e7ee8cd1a39ec47d1b69026","user":{"login":"tottakai","id":848916,"avatar_url":"https://avatars.githubusercontent.com/u/848916?v=3","gravatar_id":"","url":"https://api.github.com/users/tottakai","html_url":"https://github.com/tottakai","followers_url":"https://api.github.com/users/tottakai/followers","following_url":"https://api.github.com/users/tottakai/following{/other_user}","gists_url":"https://api.github.com/users/tottakai/gists{/gist_id}","starred_url":"https://api.github.com/users/tottakai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tottakai/subscriptions","organizations_url":"https://api.github.com/users/tottakai/orgs","repos_url":"https://api.github.com/users/tottakai/repos","events_url":"https://api.github.com/users/tottakai/events{/privacy}","received_events_url":"https://api.github.com/users/tottakai/received_events","type":"User","site_admin":false},"repo":{"id":43200170,"name":"RxSwift","full_name":"tottakai/RxSwift","owner":{"login":"tottakai","id":848916,"avatar_url":"https://avatars.githubusercontent.com/u/848916?v=3","gravatar_id":"","url":"https://api.github.com/users/tottakai","html_url":"https://github.com/tottakai","followers_url":"https://api.github.com/users/tottakai/followers","following_url":"https://api.github.com/users/tottakai/following{/other_user}","gists_url":"https://api.github.com/users/tottakai/gists{/gist_id}","starred_url":"https://api.github.com/users/tottakai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tottakai/subscriptions","organizations_url":"https://api.github.com/users/tottakai/orgs","repos_url":"https://api.github.com/users/tottakai/repos","events_url":"https://api.github.com/users/tottakai/events{/privacy}","received_events_url":"https://api.github.com/users/tottakai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tottakai/RxSwift","description":"Reactive Programming in Swift","fork":true,"url":"https://api.github.com/repos/tottakai/RxSwift","forks_url":"https://api.github.com/repos/tottakai/RxSwift/forks","keys_url":"https://api.github.com/repos/tottakai/RxSwift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tottakai/RxSwift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tottakai/RxSwift/teams","hooks_url":"https://api.github.com/repos/tottakai/RxSwift/hooks","issue_events_url":"https://api.github.com/repos/tottakai/RxSwift/issues/events{/number}","events_url":"https://api.github.com/repos/tottakai/RxSwift/events","assignees_url":"https://api.github.com/repos/tottakai/RxSwift/assignees{/user}","branches_url":"https://api.github.com/repos/tottakai/RxSwift/branches{/branch}","tags_url":"https://api.github.com/repos/tottakai/RxSwift/tags","blobs_url":"https://api.github.com/repos/tottakai/RxSwift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tottakai/RxSwift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tottakai/RxSwift/git/refs{/sha}","trees_url":"https://api.github.com/repos/tottakai/RxSwift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tottakai/RxSwift/statuses/{sha}","languages_url":"https://api.github.com/repos/tottakai/RxSwift/languages","stargazers_url":"https://api.github.com/repos/tottakai/RxSwift/stargazers","contributors_url":"https://api.github.com/repos/tottakai/RxSwift/contributors","subscribers_url":"https://api.github.com/repos/tottakai/RxSwift/subscribers","subscription_url":"https://api.github.com/repos/tottakai/RxSwift/subscription","commits_url":"https://api.github.com/repos/tottakai/RxSwift/commits{/sha}","git_commits_url":"https://api.github.com/repos/tottakai/RxSwift/git/commits{/sha}","comments_url":"https://api.github.com/repos/tottakai/RxSwift/comments{/number}","issue_comment_url":"https://api.github.com/repos/tottakai/RxSwift/issues/comments{/number}","contents_url":"https://api.github.com/repos/tottakai/RxSwift/contents/{+path}","compare_url":"https://api.github.com/repos/tottakai/RxSwift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tottakai/RxSwift/merges","archive_url":"https://api.github.com/repos/tottakai/RxSwift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tottakai/RxSwift/downloads","issues_url":"https://api.github.com/repos/tottakai/RxSwift/issues{/number}","pulls_url":"https://api.github.com/repos/tottakai/RxSwift/pulls{/number}","milestones_url":"https://api.github.com/repos/tottakai/RxSwift/milestones{/number}","notifications_url":"https://api.github.com/repos/tottakai/RxSwift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tottakai/RxSwift/labels{/name}","releases_url":"https://api.github.com/repos/tottakai/RxSwift/releases{/id}","created_at":"2015-09-26T09:41:30Z","updated_at":"2015-09-26T09:41:35Z","pushed_at":"2015-10-26T19:30:20Z","git_url":"git://github.com/tottakai/RxSwift.git","ssh_url":"git@github.com:tottakai/RxSwift.git","clone_url":"https://github.com/tottakai/RxSwift.git","svn_url":"https://github.com/tottakai/RxSwift","homepage":"","size":2646,"stargazers_count":0,"watchers_count":0,"language":"Swift","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":"develop"}},"base":{"label":"ReactiveX:develop","ref":"develop","sha":"f617132c375a0575abd1fb758d5ffe5e281faed7","user":{"login":"ReactiveX","id":6407041,"avatar_url":"https://avatars.githubusercontent.com/u/6407041?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveX","html_url":"https://github.com/ReactiveX","followers_url":"https://api.github.com/users/ReactiveX/followers","following_url":"https://api.github.com/users/ReactiveX/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveX/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveX/subscriptions","organizations_url":"https://api.github.com/users/ReactiveX/orgs","repos_url":"https://api.github.com/users/ReactiveX/repos","events_url":"https://api.github.com/users/ReactiveX/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveX/received_events","type":"Organization","site_admin":false},"repo":{"id":33569135,"name":"RxSwift","full_name":"ReactiveX/RxSwift","owner":{"login":"ReactiveX","id":6407041,"avatar_url":"https://avatars.githubusercontent.com/u/6407041?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveX","html_url":"https://github.com/ReactiveX","followers_url":"https://api.github.com/users/ReactiveX/followers","following_url":"https://api.github.com/users/ReactiveX/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveX/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveX/subscriptions","organizations_url":"https://api.github.com/users/ReactiveX/orgs","repos_url":"https://api.github.com/users/ReactiveX/repos","events_url":"https://api.github.com/users/ReactiveX/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ReactiveX/RxSwift","description":"Reactive Programming in Swift","fork":false,"url":"https://api.github.com/repos/ReactiveX/RxSwift","forks_url":"https://api.github.com/repos/ReactiveX/RxSwift/forks","keys_url":"https://api.github.com/repos/ReactiveX/RxSwift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ReactiveX/RxSwift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ReactiveX/RxSwift/teams","hooks_url":"https://api.github.com/repos/ReactiveX/RxSwift/hooks","issue_events_url":"https://api.github.com/repos/ReactiveX/RxSwift/issues/events{/number}","events_url":"https://api.github.com/repos/ReactiveX/RxSwift/events","assignees_url":"https://api.github.com/repos/ReactiveX/RxSwift/assignees{/user}","branches_url":"https://api.github.com/repos/ReactiveX/RxSwift/branches{/branch}","tags_url":"https://api.github.com/repos/ReactiveX/RxSwift/tags","blobs_url":"https://api.github.com/repos/ReactiveX/RxSwift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ReactiveX/RxSwift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ReactiveX/RxSwift/git/refs{/sha}","trees_url":"https://api.github.com/repos/ReactiveX/RxSwift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ReactiveX/RxSwift/statuses/{sha}","languages_url":"https://api.github.com/repos/ReactiveX/RxSwift/languages","stargazers_url":"https://api.github.com/repos/ReactiveX/RxSwift/stargazers","contributors_url":"https://api.github.com/repos/ReactiveX/RxSwift/contributors","subscribers_url":"https://api.github.com/repos/ReactiveX/RxSwift/subscribers","subscription_url":"https://api.github.com/repos/ReactiveX/RxSwift/subscription","commits_url":"https://api.github.com/repos/ReactiveX/RxSwift/commits{/sha}","git_commits_url":"https://api.github.com/repos/ReactiveX/RxSwift/git/commits{/sha}","comments_url":"https://api.github.com/repos/ReactiveX/RxSwift/comments{/number}","issue_comment_url":"https://api.github.com/repos/ReactiveX/RxSwift/issues/comments{/number}","contents_url":"https://api.github.com/repos/ReactiveX/RxSwift/contents/{+path}","compare_url":"https://api.github.com/repos/ReactiveX/RxSwift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ReactiveX/RxSwift/merges","archive_url":"https://api.github.com/repos/ReactiveX/RxSwift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ReactiveX/RxSwift/downloads","issues_url":"https://api.github.com/repos/ReactiveX/RxSwift/issues{/number}","pulls_url":"https://api.github.com/repos/ReactiveX/RxSwift/pulls{/number}","milestones_url":"https://api.github.com/repos/ReactiveX/RxSwift/milestones{/number}","notifications_url":"https://api.github.com/repos/ReactiveX/RxSwift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ReactiveX/RxSwift/labels{/name}","releases_url":"https://api.github.com/repos/ReactiveX/RxSwift/releases{/id}","created_at":"2015-04-07T21:25:17Z","updated_at":"2015-10-26T20:51:20Z","pushed_at":"2015-10-26T19:31:52Z","git_url":"git://github.com/ReactiveX/RxSwift.git","ssh_url":"git@github.com:ReactiveX/RxSwift.git","clone_url":"https://github.com/ReactiveX/RxSwift.git","svn_url":"https://github.com/ReactiveX/RxSwift","homepage":"","size":7912,"stargazers_count":1624,"watchers_count":1624,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":127,"mirror_url":null,"open_issues_count":12,"forks":127,"open_issues":12,"watchers":1624,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214"},"html":{"href":"https://github.com/ReactiveX/RxSwift/pull/214"},"issue":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/issues/214"},"comments":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/issues/214/comments"},"review_comments":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214/comments"},"review_comment":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/pulls/214/commits"},"statuses":{"href":"https://api.github.com/repos/ReactiveX/RxSwift/statuses/cc8e57a8964d89807e7ee8cd1a39ec47d1b69026"}}}}