Returns a Boolean value that indicates whether the set has no members in common with the given sequence.
SDK
- Xcode 8.3+
Framework
- Swift Standard Library
Declaration
Parameters
other
A sequence of elements.
other
must be finite.
Return Value
true
if the set has no elements in common with other
; otherwise, false
.
Discussion
In the following example, the employees
set is disjoint with the elements of the visitors
array because no name appears in both.
let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
let visitors = ["Marcia", "Nathaniel", "Olivia"]
print(employees.isDisjoint(with: visitors))
// Prints "true"