Open ShikiSuen opened 1 year ago
My initial reaction is that this API does not carry its weight as sugar. Can you supply a couple examples of use sites to explain how you would like to use it and why it's better than other alternatives?
@stephentyrone The following example will throw wrong result if the incoming NSEvent has no device-independent modifier flags:
import AppKit
func handle(event: NSEvent, sender: Any?) -> Bool {
let mustBeAnyOfTheseFlags: NSEvent.ModifierFlags = [.shift, .option]
return mustBeAnyOfTheseFlags.contains(event.modifierFlags.intersection(.deviceIndependentFlagsMask))
}
This is the occasion when .containsEntity()
does its job.
Do you mind if I extract the documentation hole into a new issue since it can be dealt with separately?
@AnthonyLatsis I don't mind.
Motivation This is to solve any confusions provided by OptionSet.contains() in case that the given parameter is empty. See: https://github.com/apple/swift/issues/68537
By default, OptionSet.contains([]) always return
true
regardless whether itself is empty. However, this only makes sense in mathematics.Solution
State how OptionSet.contains() behaves with empty parameters in documentation.
Add the following method.