Last active
May 23, 2016 17:47
-
-
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.
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
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