---
title: "map(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/result/map(_:)"
---

# map(_:)

Returns a new result, mapping any success value using the given transformation.

## Declaration

```swift
func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> where NewSuccess : ~Copyable
```

## Parameters

- `transform`: A closure that takes the success value of this instance.

## Return Value

Return Value A Result instance with the result of evaluating transform as the new success value if this instance represents a success.

## Discussion

Discussion Use this method when you need to transform the value of a Result instance when it represents a success. The following example transforms the integer success value of a result into a string: func getNextInteger() -> Result<Int, Error> { /* ... */ }

let integerResult = getNextInteger() // integerResult == .success(5) let stringResult = integerResult.map { String($0) } // stringResult == .success("5")

## See Also

### Transforming a Result

- [mapError(_:)](swift/result/maperror(_:).md)
- [flatMap(_:)](swift/result/flatmap(_:).md)
- [flatMapError(_:)](swift/result/flatmaperror(_:).md)
