---
title: "padding(toLength:withPad:startingAt:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/padding(tolength:withpad:startingat:)"
---

# padding(toLength:withPad:startingAt:)

Returns a new string formed from the String by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string.

## Declaration

```swift
func padding<T>(toLength newLength: Int, withPad padString: T, startingAt padIndex: Int) -> String where T : StringProtocol
```
