<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/FormatStyle/ComponentDisplayOption/omitWhen(_:matches:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV11FormatStyleV22ComponentDisplayOptionV8omitWhen_7matchesAgE0E0O_ShySSGtFZ"
  },
  "title" : "omitWhen(_:matches:)"
}
-->

# omitWhen(_:matches:)

Returns a display option that omits the component when a specified component meets the specified requirements.

```
static func omitWhen(_ component: URL.FormatStyle.Component, matches requirements: Set<String>) -> URL.FormatStyle.ComponentDisplayOption
```

## Parameters

`component`

A component to compare. This may or may not be the component the strategy modifies. For example, a display option for the password might match against known values for the user.

`requirements`

A set of string values to match against. Matching any member of the set informs the format style to omit the component.

## Return Value

A display option that omits the component when a specified component meets the specified requirements.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)