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

# currency(code:)

Returns a format style to use integer currency notation.

## Declaration

```swift
static func currency<V>(code: String) -> Self where Self == IntegerFormatStyle<V>.Currency, V : BinaryInteger
```

## 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 An integer 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 IntegerFormatStyle. You typically do this when calling the formatted methods of types that conform to BinaryInteger. The following example creates an array of integers, then uses formatted(_:) and the currency style provided by this method to format the integers as US dollars: let nums: [Int] = [100, 1000, 10000, 100000, 1000000] let currencyNums = nums.map { $0.formatted(     .currency(code:"USD")) } // ["$100.00", "$1,000.00", "$10,000.00", "$100,000.00", "$1,000,000.00"]

## See Also

### Applying currency styles

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