https://github.com/mickamy/distinctuntilchangedbugexample
https://github.com/mickamy/distinctuntilchangedbugexample
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mickamy/distinctuntilchangedbugexample
- Owner: mickamy
- Created: 2019-10-31T12:13:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-31T12:40:02.000Z (over 6 years ago)
- Last Synced: 2025-02-27T09:57:23.610Z (over 1 year ago)
- Language: Swift
- Size: 307 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DistinctUntilChangedBugExample
`Observable<(Bool, Bool)>.distinctUntilChanged` behaives unexpectedly.
```Swift
Observable<(Bool, Bool)>
.of(
(false, false),
(true, false),
(false, true),
(true, true)
)
.distinctUntilChanged { $0 == $1 }
.subscribe(onNext: { print("onNext: \($0)") })
.disposed(by: bag)
```
I expected the following output,
```
onNext: (false, false)
onNext: (true, false)
onNext: (false, true)
onNext: (true, true)
```
but actually the result is like below
```
onNext: (false, false)
onNext: (true, false)
onNext: (true, true)
```
---
I though it might be a bug belongs to `Swift` language, but it's not.
```Swift
print((false, false) == (true, false)) // false
print((false, false) == (true, false)) // false
print((false, false) == (true, false)) // false
```