---
title: "appending(_:)"
framework: diskimagekit
role: symbol
role_heading: Instance Method
path: "diskimagekit/diskimage/appending(_:)-4wifj"
---

# appending(_:)

Appends a layer to this disk image, creating or extending a stack.

## Declaration

```swift
consuming func appending(_ layer: consuming DiskImage) throws -> any StackedImage
```

## Parameters

- `layer`: An existing disk image to append as the new top layer.

## Return Value

Return Value A StackedImage containing all layers.

## Discussion

Discussion note: The framework allows only one cache layer per stacked disk image. This method creates a stacked disk image by appending a layer to either a base image or an existing stacked image. When the image is already a stacked image, the framework adds the new layer on top of the existing stack. note: IncompatibleStackingError if the appended layer isn’t compatible with the stack.

## See Also

### Appending layers and resizing existing images

- [DiskImage.StackableLayer](diskimagekit/diskimage/stackablelayer.md)
