<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/SIMDMask/replacing(with:where:)-5eb2n",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s8SIMDMaskVss6SIMD32Vys5Int16VGRszrlE9replacing4with5whereAByAGGAK_AKtF"
  },
  "title" : "replacing(with:where:)"
}
-->

# replacing(with:where:)

Returns a copy of this vector, with elements replaced by elements of
`other` in the lanes where `mask` is `true`.

```
func replacing(with other: SIMDMask<Storage>, where mask: SIMDMask<Storage>) -> SIMDMask<Storage>
```

## Discussion

Equivalent to:

```
var result = Self()
for i in indices {
  result[i] = mask[i] ? other[i] : self[i]
}
```

---

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)