Last active
May 7, 2016 18:53
-
-
Save trK54Ylmz/014e271b36727e816bf7 to your computer and use it in GitHub Desktop.
String helper functions for Scala lang
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
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