---
title: "hasSuffix(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsstring/hassuffix(_:)"
---

# hasSuffix(_:)

Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver.

## Declaration

```swift
func hasSuffix(_ str: String) -> Bool
```

## Parameters

- `str`: A string.

## Return Value

Return Value true if aString matches the ending characters of the receiver, otherwise false. Returns false if aString is empty.

## Discussion

Discussion This method is a convenience for comparing strings using the NSAnchoredSearch and NSBackwardsSearch options. See String Programming Guide for more information.

## See Also

### Identifying and Comparing Strings

- [caseInsensitiveCompare(_:)](foundation/nsstring/caseinsensitivecompare(_:).md)
- [localizedCaseInsensitiveCompare(_:)](foundation/nsstring/localizedcaseinsensitivecompare(_:).md)
- [compare(_:)](foundation/nsstring/compare(_:).md)
- [localizedCompare(_:)](foundation/nsstring/localizedcompare(_:).md)
- [compare(_:options:)](foundation/nsstring/compare(_:options:).md)
- [compare(_:options:range:)](foundation/nsstring/compare(_:options:range:).md)
- [compare(_:options:range:locale:)](foundation/nsstring/compare(_:options:range:locale:).md)
- [localizedStandardCompare(_:)](foundation/nsstring/localizedstandardcompare(_:).md)
- [hasPrefix(_:)](foundation/nsstring/hasprefix(_:).md)
- [isEqual(to:)](foundation/nsstring/isequal(to:).md)
- [hash](foundation/nsstring/hash.md)
- [NSString.CompareOptions](foundation/nsstring/compareoptions.md)
- [NSString.EncodingConversionOptions](foundation/nsstring/encodingconversionoptions.md)
