I study Scala and run through the following task - if the line is empty, then return zero, otherwise in uppercase.
Apache Commons has two features that together make up the problem. In Haskell, I just write:
upperCaseOrNull = StringUtils.stripToNull . StringUtils.upperCase
However, I cannot find a way to make the composition easy and clean in Scala. the shortest path I found is as follows:
def upperCaseOrNull (string:String) = StringUtils.stripToNull (StringUtils.upperCase(string)) def upperCaseOrNull = StringUtils.stripToNull _ compose StringUtils.upperCase _
Does Scala offer a more concise syntax, perhaps without all of these underscores?
source share