Skip to content
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

StringProtocol.contains(_:) returns false for empty string #891

Open
yo1995 opened this issue Aug 29, 2024 · 1 comment
Open

StringProtocol.contains(_:) returns false for empty string #891

yo1995 opened this issue Aug 29, 2024 · 1 comment

Comments

@yo1995
Copy link

yo1995 commented Aug 29, 2024

Description

Please see the Swift forum post for details: https://forums.swift.org/t/nsstring-contains-returns-false-for-empty-string-argument/3949

It seems that the current implementation in Foundation has this problem, while the implementation in _StringProcessing doesn't.

// Without importing Foundation
"foo".contains("") // ⟹ true

import Foundation
"foo".contains("") // ⟹ false
@itingliu
Copy link
Contributor

We're aware of this discrepancy, but this is one of those behavior we need to maintain for compatibility reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants