Skip to content

Instantly share code, notes, and snippets.

@asflierl
Created December 11, 2015 12:30
Show Gist options
  • Save asflierl/9b701e1eac6d21c9a551 to your computer and use it in GitHub Desktop.
Save asflierl/9b701e1eac6d21c9a551 to your computer and use it in GitHub Desktop.
import java.lang.Character.{isWhitespace, charCount}
implicit class SuperString(str: String) extends AnyVal {
def isBlank: Boolean = {
@tailrec def check(index: Int): Boolean =
if (index >= str.length) true
else {
val cp = str.codePointAt(index)
if (isWhitespace(cp)) check(index + charCount(cp)) else false
}
check(0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment