Created
December 9, 2017 18:50
-
-
Save munirwanis/7c578075853d432868f764d0047b879c to your computer and use it in GitHub Desktop.
Reduce String array to a single String separated by new lines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Sequence where Iterator.Element == String { | |
var reduced: String { | |
return self.reduce("", { $0 == "" ? $1 : $0 + "\n" + $1 }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: