---
title: "currency(code:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/formatstyle/currency(code:)-6fhr2"
---

# currency(code:)

Returns a format style to use decimal currency notation.

## Declaration

```swift
static func currency(code: String) -> Self
```

## Parameters

- `code`: The currency code to use, such as EUR or JPY. See ISO-4217 for a list of valid codes.

## Return Value

Return Value A decimal format style that uses the specified currency code.

## Discussion

Discussion Use the dot-notation form of this method when the call point allows the use of Decimal.FormatStyle. You typically do this when calling the formatted(_:) method of Decimal. The following example creates an array of decimals, then uses formatted(_:) and the currency style provided by this method to format the values as US dollars. let nums: [Decimal] = [100.01, 1000.02, 10000.03, 100000.04, 1000000.05] let currencyNums = nums.map { $0.formatted(     .currency(code:"USD")) } // ["$100.01", "$1,000.02", "$10,000.03", "$100,000.04", "$1,000,000.05"]

## See Also

### Applying currency styles

- [currency(code:)](foundation/formatstyle/currency(code:)-is0v.md)
- [currency(code:)](foundation/formatstyle/currency(code:)-1yg68.md)
