You can use require(), which is like an assert, to check if an argument satisfies an arbitrary condition. Ofcourse it's a runtime check, not a compile-time check.
If you want to automatically use empty
string whenever null is passed, you could do something like this:
Note that in Scala, "if" is an expression, not a statement (as it is in
Java) - it evaluates to a value.