Skip to content

Instantly share code, notes, and snippets.

@trK54Ylmz
Last active May 7, 2016 18:53
Show Gist options
  • Save trK54Ylmz/014e271b36727e816bf7 to your computer and use it in GitHub Desktop.
Save trK54Ylmz/014e271b36727e816bf7 to your computer and use it in GitHub Desktop.
String helper functions for Scala lang
object StringUtils
{
def isEmpty(str: String): Boolean = str == null || str.trim == ""
def isAnyEmpty(arr: String*): Boolean = arr.count(str => str == null || str.trim == "") > 0
def getFirstEmpty(arr: String*): String = {
val group = arr.filter(str => str == null || str.trim == "")
if (group.isEmpty) null else group.head
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment