Joining Attributes
January 5th, 2016
Since the first release, Attributed has had a join()
extension function for sequences of attributed-string-like values:
This allows for attribute-less portions in the final attributed string. In Attributed 0.3.0, the join()
extension is added to sequences of attribute functions as well.
When all attributes must be nested individual, applying a number of attributes is harder to follow. For example, with a red foreground color, black background color, and single underline:
With the new join()
, these attributes can be combined into a single function:
This makes it easy to repeatedly use the joined attributes, without repeating the nested structure:
Attributed is available on Github. I recommend using Carthage to integrate it with a project, by adding this line to your Cartfile
: