Skip to content

Instantly share code, notes, and snippets.

@dmyersturnbull
Last active May 23, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmyersturnbull/9c3bf02240013dd446c31cd70eabb309 to your computer and use it in GitHub Desktop.
Save dmyersturnbull/9c3bf02240013dd446c31cd70eabb309 to your computer and use it in GitHub Desktop.
Left- and right- pad a string with ^ and $, for rare cases where it makes operations much more clear.
private implicit class Paddable(string: String) {
/** Left-pad this string. */
def ^(end: Int): String = " " * (end - string.length) + string
/** Right-pad this string. */
def $(end: Int): String = string + " " * (end - string.length)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment