Suppose I have String parameter coming from a query string request parameters. As you know the parameter may be missing or may be there but value is empty string.
In groovy language I can simply do something like
List lst = words?.split(',')
if words was null, lst would be null instead of throwing NPE
what is similar shortcut in scala?
Option[String] is not an option here as words is of type String as it is coming from query string.
If you want to keep nulls around,
But what you should do is get rid of the nulls. If some API (Java, most likely) may return a
null, wrap its call inOption(), to get a properOptioninstead. If some API needs to be passed anull, pass it anoption.orNull.Inside your own code, don’t let anything be
null.