Contents

format(_:)

Creates a locale-aware string representation of the value.

Declaration

func format(_ value: Base) -> String

Parameters

  • value:

    The sequence of elements to format.

Return Value

A string representation of the provided sequence.

Discussion

The format(_:) instance method generates a string from the provided sequence. Once you create a style, you can use it to format similar sequences multiple times. For example:

let percentStyle = ListFormatStyle<IntegerFormatStyle.Percent, [Int]>(memberStyle: .percent)
percentStyle.format([92, 98]) // 92% and 98%
percentStyle.format([67, 72, 99]) // 67%, 72%, and 99%