Created
March 28, 2019 13:09
-
-
Save stargt/935f8c50f149fcfd25b0985a9b6b7639 to your computer and use it in GitHub Desktop.
string.spacer.kt
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
/* Put space into string between chunks of same length */ | |
fun String.spacer(unitLength: Int = Int.MAX_VALUE, spaceCharacter: String = " "): String = chunked(unitLength).joinToString(spaceCharacter) | |
/** | |
* e.g. | |
* "123456789012345678".spacer(4) => "1234 5678 9012 3456 78" | |
* "123456789012345678".spacer(4, "@") => "1234@5678@9012@3456@78" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment