A library containing the extension to the sequence protocol where an element conform to the CustomStringConvertible protocol (could be optional). Also, contains a helper structure with the convenience methods to convert sequences
- Converts sequences to strings
- Removes empty elements
- Removes nil elements
- Correctly puts separators before, after and between the elements
- Small
- 100% unit tested
NumeralEndings is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SequenceConverter"
The classic example is resolving correct string with a punctuation from a first name, middle name and last name in the case when it is possible for each element to be empty or nil.
let formatted = SequenceConverter.middleSpaceFormat("Ivanov", "Ivan", "Ivanovich" )
// "Ivanov Ivan Ivanovich"
let formatted = SequenceConverter.middleSpaceFormat("Ivanov", "Ivan" )
// "Ivanov Ivan"
// Custom separators
["1", "", nil, "", "4", "5"].toStringWithSeparators(before: "<-", between: "|", after: "->")
//"<-1|4|5->"
Andrey Volobuev blob8129@gmail.com
If you have any questions, drop me an email.