Created
November 1, 2019 13:10
-
-
Save msewell/21ff763ee0fa1c80a32fc1f8ae27543e to your computer and use it in GitHub Desktop.
Random String containing of Block elements (an alternative to Lorem Ipsum?)
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 String { | |
private static let blockElements = (9600...9631) | |
.compactMap { Unicode.Scalar($0) } | |
.map { Character($0) } | |
static func blocks(_ length: Int = 8) -> String { | |
let choices = (1...length) | |
.map { _ in String.blockElements.randomElement()! } | |
return String(choices) | |
} | |
} | |
// Example print: ▕▛▉▐▝▃██▖█▐▊█▂▖▚░▗▇░▒▘█▆█▁█▏▒▓▚▋ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment