-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement equality for NSNull #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
let null_4: NSNull? = nil | ||
|
||
XCTAssertEqual(null_1, null_2) | ||
XCTAssertEqual(null_1, null_3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NSNull exposed from objc should also have the property of a singleton. So I would also expect that XCTAssertTrue(null_1 === null_2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but wouldn't that break our NSNull.swift implementation? Should I do a conditional assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this particular case it preserves the effective functioning behavior of the "singleton-ness" of NSNull without needing a factory pattern init method. I think it is in the spirit of the API to preserve this and add an overload of the === operator to satisfy the expectation that one construction of NSNull() is to be treated as exactly the same as another construction of NSNull()
…dation Conflicts: TestFoundation/main.swift
@phausler |
looks great! |
Implement equality for NSNull
Implemented the
isEqual
method forNSNull
, that always returnstrue
for twoNSNull
instances - thus giving it singleton semantics. (too bad we don't have factory methods or can't return references from initializers)Added tests.