Skip to content

Instantly share code, notes, and snippets.

@msewell
Created November 1, 2019 13:10
Show Gist options
  • Save msewell/21ff763ee0fa1c80a32fc1f8ae27543e to your computer and use it in GitHub Desktop.
Save msewell/21ff763ee0fa1c80a32fc1f8ae27543e to your computer and use it in GitHub Desktop.
Random String containing of Block elements (an alternative to Lorem Ipsum?)
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