<!--
{
  "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/DefaultStringInterpolation/appendInterpolation(_:default:)-ue3g",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s26DefaultStringInterpolationV06appendC0_7defaultyxSg_SSts06CustomB11ConvertibleRzs20TextOutputStreamableRzlF"
  },
  "title" : "appendInterpolation(_:default:)"
}
-->

# appendInterpolation(_:default:)

Interpolates the given optional value’s textual representation, or the
specified default string, into the string literal being created.

```
mutating func appendInterpolation<T>(_ value: T?, default: String) where T : CustomStringConvertible, T : TextOutputStreamable
```

## Parameters

`value`

The value to include in a string interpolation, if non-`nil`.

`default`

The string to include if `value` is `nil`.

## Discussion

You don’t need to call this method directly. It’s used by the compiler
when interpreting string interpolations where you provide a `default`
parameter. For example, the following code implicitly calls this method,
using the value of the `default` parameter when `value` is `nil`:

```
var age: Int? = 48
print("Your age is \(age, default: "unknown")")
// Prints: Your age is 48
age = nil
print("Your age is \(age, default: "unknown")")
// Prints: Your age is unknown
```

---

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)